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
 General SQL Server Forums
 New to SQL Server Programming
 Simple CASE Question (really easy)

Author  Topic 

funk.phenomena
Posting Yak Master

121 Posts

Posted - 2012-03-15 : 16:49:37
I have the following CASE Statement:


CASE WHEN COLUMN1=0 OR COLUMN2=0 OR COLUMN=4 OR WHEN COLUMN5=0 OR COLUMN6=0 OR COLUMN7=0 R WHEN COLUMN8=0 OR COLUMN9=0 OR COLUMN=0
THEN 'FAIL' ELSE 'PASS' END

Basically if any columns=0, it outputs 'fail'.

Is there any easier/simpler way of writing this statement?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-03-15 : 16:55:47
WHEN COLUMN1 * COLUMN2 * COLUMN4 * COLUMN5 * COLUMN6 * COLUMN7 * COLUMN8 * COLUMN9 * COLUMN10=0 THEN..

I hope they're all of integer or any of numeric data type

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2012-03-15 : 17:14:33
CASE WHEN 0 IN (Column1, Column2, Column3, Column4, Column5) THEN 'Fail' ELSE 'Pass' END



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page
   

- Advertisement -