| Author |
Topic |
|
jeff06
Posting Yak Master
166 Posts |
Posted - 2007-02-13 : 13:15:22
|
| not(a>0 and b>0)how to do that in sql sever?Thanks |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-02-13 : 13:16:44
|
| Exactly as is.Peter LarssonHelsingborg, Sweden |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2007-02-13 : 13:28:18
|
it is really faster to log onto SQL Team, create a new post, type it in, and wait for a response rather than just to try it ??? - Jeffhttp://weblogs.sqlteam.com/JeffS |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2007-02-13 : 13:30:16
|
quote: Originally posted by X002548 WHERE a<=0 AND b <=0
that's not correct. If you have:not (a and b)and you want to move the negation inside the parens, you get:(not a or not b)so the answer in this case would be:(A<=0 or b<=0)- Jeffhttp://weblogs.sqlteam.com/JeffS |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2007-02-13 : 13:36:09
|
| Don't forget nulls!CODO ERGO SUM |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-02-13 : 13:41:02
|
| [code]-- prepare sample datadeclare @test table (a int, b int)insert @testselect 2, 2 union allselect 2, -2 union allselect -2, 2 union allselect -2, -2 union allselect 2, null union allselect null, 2 union allselect -2, null union allselect null, -2-- show some resultSELECT 'jeff06', a, bFROM @testwhere not(a>0 and b>0)SELECT 'X002548', a, bFROM @testwhere a<=0 AND b <=0SELECT 'jsmith8858', a, bFROM @testwhere a<=0 or b <=0[/code]Peter LarssonHelsingborg, Sweden |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2007-02-13 : 14:13:32
|
quote: Got a link? I still don't buy it
It's basic boolean algebra. http://en.wikipedia.org/wiki/De_Morgan%27s_lawsShould be required knowledge for anyone who ever writes a WHERE clause or does any computer programming ....- Jeffhttp://weblogs.sqlteam.com/JeffS |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2007-02-13 : 14:31:55
|
| Think about it logically: If they are not both greater than zero, then one or both of them is less than or equal to zero. Right?- Jeffhttp://weblogs.sqlteam.com/JeffS |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
|