SQL Query help

Firus

Senior member
Nov 16, 2001
525
0
0
I'm just wondering if this is possible:

can you do a select so that if the select statement returns a number (1 or 0) it displays specified text in the results field?

example:

select emp, position, if(primary_indicator=1, 'yes', 'no')
from employees

So what i am trying to do here is replace the the primary position indicator with a 'yes' if its 1 in the table, or a 'no' if anything else. I know you could do some transact SQL, but im just wondering here...

Thanks
 

Firus

Senior member
Nov 16, 2001
525
0
0
Ahhh, its MS SQL Server. Which does not have a 'decode', but your info sent me on the right track for google-ing. I found out you have to use a Case statement in your select.

Thanks :)