Click here to Skip to main content
15,922,309 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how should I write for select statement including if else condititon

I write as below statement and give error, so how should I write for that

SQL
ORDER.Order_Id as 'id',
ORDER.Released
IF(ORDER.Released = 1) PRINT 'Released'
ELSE PRINT 'Not Released'
from ORDER


thanks,
ttds
Posted
Updated 17-Jan-13 17:14pm
v2
Comments
PIEBALDconsult 17-Jan-13 22:12pm    
I can't tell what you want, but maybe you want CASE ORDER.Released THEN 'Released' ELSE 'Not Released' END
PIEBALDconsult 17-Jan-13 22:12pm    
Are you looking for

CASE ORDER.Released WHEN 1 THEN 'Released' ELSE 'Not Released' END?


Oh, sure, now the earlier post shows up. :rolleyes:

1 solution

This should do it

SQL
SELECT
    O.Order_ID AS 'id',
    O.Released,
    CASE WHEN O.Released = 1 THEN 'Released' ELSE 'Not Released' END AS ReleaseStatus
FROM Order AS O
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900