SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Old Forums
 CLOSED - General SQL Server
 Imbedding If ..else in query
 Forum Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

kaus
Posting Yak Master

179 Posts

Posted - 09/01/2004 :  13:17:46  Show Profile
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

USA
36601 Posts

Posted - 09/01/2004 :  13:22:08  Show Profile  Visit tkizer's Homepage
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 - 09/01/2004 :  13:32:20  Show Profile
Thanks
Go to Top of Page
  Previous Topic Topic Next Topic  
 Forum Locked
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000