SQL: show description in text instead of bit value
I have an attribute declared as bit: (true or false).
For example:
SELECT myBit FROM [table]
=> it will show: 1 or 0
I would like to show: 'Valid' and 'Invalid' for 1 and 0 r开发者_JAVA百科espectively.
How could I add IF ELSE statement in the SELECT statement?
For SQL Server, you can use a CASE statement:
SELECT CASE myBit WHEN 1 THEN 'Valid' WHEN 0 THEN 'Invalid' END As MyColumn
FROM [table]
精彩评论