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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2001-04-13 : 08:34:02
|
Valter Borges writes "I was wondering if someone knew a shorter way to do the following
DECLARE @x int select @X = COUNT(DISTINCT Corrosive) from MyTable where UOM = 'en' AND Corrosive = 'Corrosive' DECLARE @y int select @y = COUNT(DISTINCT Corrosive) from MyTable where UOM = 'en' AND Corrosive = 'Non-Corrosive'
DECLARE @z int SELECT @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*/ END
PRINT @z" |
|
|
|
|
|