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 |
daniel50096230
Yak Posting Veteran
99 Posts |
Posted - 2013-01-14 : 23:11:35
|
I have my sql as below:SELECT Case When Product_ID = 'A' Then 'Active' When Product_ID = 'B' Then 'Obselete' End As Description Case When Product_ID = 'A' Then 'Good' When Product_ID = 'B' Then 'Bad' End As ConditionFROM Table_ASince the two Case condition is the same, is there possible to make it into one?Eg. Case When Product_ID = 'A' THEN 'Active' As Description, 'Good' As Condition |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-01-15 : 00:07:39
|
Nope. CASE is not a control flow statement but its just a conditional expression.if you really need to do it you need thisSELECT 'Active' AS Description,'Good' AS ConditionFROM Table_AWHERE Product_ID = 'A'UNION ALLSELECT 'Obselete','Bad'FROM Table_AWHERE Product_ID = 'B' ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|