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 |
|
paull
Yak Posting Veteran
50 Posts |
Posted - 2009-07-01 : 05:33:37
|
| Hi GuysCan someone please tell me what is wrong with this code? I have tried moving brackets around and it works if I drop the "OR".Case when (Q30a_Adj_Pedals = ' ' AND Version = ('1' OR '2')) then '0' endThanksP |
|
|
rajdaksha
Aged Yak Warrior
595 Posts |
Posted - 2009-07-01 : 05:47:13
|
| SELECT CASE WHEN (Q30A_ADJ_PEDALS = ' ' AND VERSION IN ('1','2')) THEN '0' END |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-07-01 : 05:48:13
|
AND (Version='1' OR Version='2')Also should be possibleAND Version in ('1','2')Fred No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
paull
Yak Posting Veteran
50 Posts |
Posted - 2009-07-01 : 05:59:54
|
| Aha!! Thanks guysEveryday is a school day as they say!! |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-07-01 : 06:17:48
|
welcome  No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
paull
Yak Posting Veteran
50 Posts |
Posted - 2009-07-01 : 06:30:17
|
| Hello again chapsThe code works but it is not doing what I had hoped for!! The code is basically saying If Q30A_AdJ_Pedals is blank AND version is either 1 or 2 make Q30a_ADJ_PEDAL = "0". When I run my code it changes everything to NULL!!!Any ideas what I might be doing wrong here?Many thanks |
 |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2009-07-01 : 11:51:53
|
You did not enclude an ELSE clause so every row that doesn't meet that criteria is going to retun NULL.quote: Originally posted by rajdaksha SELECT CASE WHEN (Q30A_ADJ_PEDALS = ' ' AND VERSION IN ('1','2')) THEN '0' ELSE Q30A_ADJ_PEDALS END
|
 |
|
|
|
|
|