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.
| Author |
Topic |
|
ValterBorges
Master Smack Fu Yak Hacker
1429 Posts |
Posted - 2001-04-11 : 12:48:56
|
| Is there an easier, shorter way to do thisDECLARE @x intselect @X = COUNT(DISTINCT Corrosive) from MyTable where UOM = 'en' AND Corrosive = 'Corrosive'DECLARE @y intselect @y = COUNT(DISTINCT Corrosive) from MyTable where UOM = 'en' AND Corrosive = 'Non-Corrosive'DECLARE @z intSELECT @z = CASE WHEN @x = 0 AND @y = 0 THEN 0 /*When None exist*/ WHEN @x = 1 AND @y = 0 THEN 1 /*When Corrosive Exists*/ WHEN @x = 0 AND @y = 1 THEN 2 /*When Non-Corrosive Exists*/ WHEN @x = 1 AND @y = 1 THEN 3 /*When Both Exist*/ ENDPRINT @z |
|
|
|
|
|