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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 IF THEN in SELECT

Author  Topic 

henrikop
Constraint Violating Yak Guru

280 Posts

Posted - 2001-06-14 : 06:36:31
Somehow can't find it in Books Online.

I can use the statement
SELECT Name, (CASE Gender WHEN 'M' THEN 'Male' ELSE 'Female' END) from tblPeople

But how can I use the IF..THEN instruction

SELECT Name, (IF Status = 'Bored' THEN 10 ELSE 5) as HappyPoints FROM tblPeople

And are nested CASE possible?

Something like

SELECT Name, (CASE Status WHEN 'Bored' THEN (CASE Message WHEN 'Y' THEN 1 ELSE 0 END) ELSE 0 END) From tblPeople

Thx,

Henri




   

- Advertisement -