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 2008 Forums
 Transact-SQL (2008)
 Multiple Select Case Statements

Author  Topic 

accesshawaii
Starting Member

1 Post

Posted - 2011-12-30 : 09:13:15
I apologize if this is the wrong section to post this. I need to do an evaluation with a few different parameters, nothing real complex but can't seem to figure out how to get it to work with SQL Case statements. Below is the sort of psuedo code of what I need.

CASE when Right([MyField],2)='AB' THEN 'NonAB' 
ELSE
WHEN [MyProject] ='A' THEN 'All'
WHEN [MyProject] ='B' THEN 'Partial'
END
TheType

As you can see it's essentially an evaluation on 2 different fields. If the first is true then it adds "AB", if not then it goes to the second evaluation to find the true statement. Any assistance that anyone could offer would be appreciated.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-12-30 : 09:15:40
[code]
CASE when Right([MyField],2)='AB' THEN 'NonAB'
ELSE
WHEN [MyProject] ='A' THEN 'All'
WHEN [MyProject] ='B' THEN 'Partial'
END
TheType
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -