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 |
|
insanepaul
Posting Yak Master
178 Posts |
Posted - 2010-11-11 : 11:46:05
|
I want to do something like the code below on a much more complex stored procedure. Basically I want to display cell 'b' from Table X if the cell a is a certain value else nullSELECTX.a,X.b case(X.a = 5 or X.a is null then X.b... ELSE NULL) as [VAT],X.cFROM X |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2010-11-11 : 11:56:28
|
That's close. Try this:SELECT X.a, CASE WHEN X.a = 5 OR X.a IS NULL THEN X.b ELSE NULL END AS VAT, X.cFROM X |
 |
|
|
insanepaul
Posting Yak Master
178 Posts |
Posted - 2010-11-11 : 12:17:09
|
quote: Originally posted by Lamprey That's close. Try this:SELECT X.a, CASE WHEN X.a = 5 OR X.a IS NULL THEN X.b ELSE NULL END AS VAT, X.cFROM X
Great that did the trick thanks |
 |
|
|
|
|
|