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 |
zhuanyi
Starting Member
5 Posts |
Posted - 2010-08-11 : 09:32:39
|
Hi,I need to code up a query for something like this:Select [something]Wherecondition incasewhen (if another_condition = A and 3rd Condition = B) then (C,D)when (if another_condition = N and 3rd Condition = E) then (F,G)else (J,K)end essentially, what I want is if A and B are met, condition could be set to either C or D, if N or E are met, then condition could be set to F or G, else condition set to J or K.However, when I run this, I kept gettingIncorrect syntax near the keyword 'Case'.Please help! Thanks! |
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2010-08-11 : 09:36:42
|
Will this work?Select [something]Where(another_condition = A and 3rd Condition = B and condition in (C,D))OR (another_condition = N and 3rd Condition = E and condition in (F,G))OR (condition in (J,K)) |
 |
|
zhuanyi
Starting Member
5 Posts |
Posted - 2010-08-11 : 09:55:43
|
Works like a charm, thanks a lot! |
 |
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2010-08-11 : 10:11:47
|
Welcome |
 |
|
|
|
|
|
|