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.

 All Forums
 Old Forums
 CLOSED - General SQL Server
 Imbedding If ..else in query

Author  Topic 

kaus
Posting Yak Master

179 Posts

Posted - 2004-09-01 : 13:17:46
I have a query like:
Select Project_Code, Project_Name, L_Proj
from Projects

L_Proj is bit data type but I want to display it as text:
If L_Proj = 1 return 'Part of Larger Project'
If L_Proj = 0 return 'Independant Project'

Can I use if statement within the query to return what I want ??

Thanks

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-09-01 : 13:22:08
Use CASE:

SELECT Project_Code, Project_Name,
L_Proj = CASE WHEN L_Proj = 1 THEN 'Part of Larger Project' ELSE 'Independent Project' END
FROM Projects

Tara
Go to Top of Page

kaus
Posting Yak Master

179 Posts

Posted - 2004-09-01 : 13:32:20
Thanks
Go to Top of Page
   

- Advertisement -