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 2005 Forums
 Transact-SQL (2005)
 Case Statements

Author  Topic 

anishap
Yak Posting Veteran

61 Posts

Posted - 2007-10-03 : 16:10:58
Can anyone help me with the case statements?
I have customized a new report for our application (vendor software). I want the end user to check 3 boxes to print (they can check all boxes or one or two).

Below is the case statement I tired in the where clause

Where
STATUS = CASE
WHEN REPORT.SEPARATED = 'y' THEN 'S'
WHEN REPORT.TERMINATED = 'y' THEN 'T'
WHEN REPORT.RETIRED ='y' THEN 'R'
END

Rightnow it is working fine if any one box is checked. Please let me if there is any other way to do this.

many thanks

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-10-03 : 16:26:39
if i understood you correctly you have to split your case into 3 cases which you have to OR:
where status = case1 or status = case2 or status = case3



_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-10-03 : 18:00:06
[code]
WHERE (STATUS = 'S' AND REPORT.SEPARATED = 'y')
OR (STATUS = 'T' AND REPORT.TERMINATED = 'y')
OR (STATUS = 'R' AND REPORT.RETIRED ='y')
[/code]
Kristen
Go to Top of Page

anishap
Yak Posting Veteran

61 Posts

Posted - 2007-10-04 : 17:09:53
Many Thanks Kristen, it is working now.
Go to Top of Page
   

- Advertisement -