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 |
|
vladimir_grigoro
Yak Posting Veteran
62 Posts |
Posted - 2003-02-20 : 08:09:09
|
| Hi All,Is there any chance to use CASE statement after WHERE?Thanks in advcance.The Rebel |
|
|
Bambola
Posting Yak Master
103 Posts |
Posted - 2003-02-20 : 09:30:28
|
| Sure. What is it that you are looking for exactly?Bambola. |
 |
|
|
ValterBorges
Master Smack Fu Yak Hacker
1429 Posts |
|
|
vladimir_grigoro
Yak Posting Veteran
62 Posts |
Posted - 2003-02-20 : 09:59:38
|
WHERE CASE X IS NULL THEN X>Y Y IS NOT NULL THEN Y<X ENDI am looking for something like that but I am not sure that is it possible.quote: Sure. What is it that you are looking for exactly?Bambola.
The Rebel |
 |
|
|
Page47
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2003-02-20 : 10:34:12
|
| You do realize that if X is null, then X>Y will evaluate to NULL, thus the predicate will always be false.Jay White{0} |
 |
|
|
vladimir_grigoro
Yak Posting Veteran
62 Posts |
Posted - 2003-02-20 : 10:37:48
|
No I just gave an example it could be any value:)quote: You do realize that if X is null, then X>Y will evaluate to NULL, thus the predicate will always be false.Jay White{0}
The Rebel |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2003-02-20 : 11:07:49
|
| I could be wrong (again) but I don't think that is syntactically correct. I think you can do something like:WHERE CASE WHEN X IS NULL THEN Y ELSE X END > CASE WHEN Y IS NULL THEN X ELSE Y ENDAgain the example doesn't make much sense with out a business reason....Am I missing something though? Any comments appreciated.Brett8-) |
 |
|
|
Onamuji
Aged Yak Warrior
504 Posts |
Posted - 2003-02-20 : 11:16:27
|
| why do you need the case at allWHERE (X IS NULL AND X>Y) OR (Y IS NOT NULL AND Y<X) |
 |
|
|
|
|
|