Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Swati Jain
Posting Yak Master
139 Posts |
Posted - 2006-09-18 : 01:38:41
|
| I want to display 'correct ' for boolen field whose value is true and 'incorrect' if its value is falseHow to write this using the sql query? |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-09-18 : 01:50:40
|
[code]select case when bitcol = 1 then 'correct' else 'incorrect' endfrom table[/code] KH |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-09-18 : 02:38:03
|
Or, if you have allowed NULL value for the boolean field,select case when bitcol = 1 then 'correct' when bitcol = 0 then 'incorrect' else 'unknown' endfrom table Peter LarssonHelsingborg, Sweden |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2006-09-18 : 03:47:50
|
quote: Originally posted by Peso Or, if you have allowed NULL value for the boolean field,select case when bitcol = 1 then 'correct' when bitcol = 0 then 'incorrect' else 'unknown' endfrom table Peter LarssonHelsingborg, Sweden
or more compact syntax:select case bitcol when 1 then 'correct' when 0 then 'incorrect' else 'unknown' endfrom table Just for the sake of completeness Harsh AthalyeIndia."Nothing is Impossible" |
 |
|
|
|
|
|