I would like to know if it is possible in an SQL query to replace some values by something else, or if I need to do that in post-processing.
Let me explain. I have this table:
|username| accepted |
|--------|----------|
| toto | NULL |
|--------|----------|
| foo | 0 |
|--------|----------|
| Rick | 1 |
|--------|----------|
| bar | 1 |
|--------|----------|
I want to know the numbers of row per value of accepted (nullable bit). I’m running this query:
SELECT [accepted], count(*) FROM my_table GROUP BY [accepted]
Which should return:
NULL 1
false 1
true 2
Is there some way to replace the accepted values by more meaningful labels? Ideally I would like to have something like:
not_available 1
not_accepted 1
accepted 2
Is that feasible with SQL server 2008 R2?
Thx.
If you have a few values: