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
 Development Tools
 Reporting Services Development
 Case Statement

Author  Topic 

ggarza75
Yak Posting Veteran

50 Posts

Posted - 2010-09-14 : 15:32:33
I'm trying to write out a single CASE statement, but with multiple WHENS in it. I guess I'm writing out the syntax wrong.

******************************************************
This is what I have so far and it works:

CASE
WHEN Code Between 1 and 24 THEN Hours ELSE NULL
END as HoursBillable
******************************************************

I'm wanting to enter another WHEN statement and looks like this, but does not work.

CASE
WHEN Code Between 1 and 24 THEN Hours ELSE
WHEN Code Between 26 and 29 THEN Hours ELSE NULL
END as HoursBillable

******************************************************

Can someone help point out what I'm doing wrong. Thanks!!

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2010-09-14 : 16:04:55
remove the ELSE before the second WHEN.

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page
   

- Advertisement -