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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 !(a>0 and b>0)

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 Larsson
Helsingborg, Sweden
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2007-02-13 : 13:28:01
WHERE a<=0 AND b <=0



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

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 ???

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

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)



- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2007-02-13 : 13:36:09
Don't forget nulls!

CODO ERGO SUM
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-02-13 : 13:41:02
[code]-- prepare sample data
declare @test table (a int, b int)

insert @test
select 2, 2 union all
select 2, -2 union all
select -2, 2 union all
select -2, -2 union all
select 2, null union all
select null, 2 union all
select -2, null union all
select null, -2

-- show some result
SELECT 'jeff06',
a,
b
FROM @test
where not(a>0 and b>0)

SELECT 'X002548',
a,
b
FROM @test
where a<=0 AND b <=0

SELECT 'jsmith8858',
a,
b
FROM @test
where a<=0 or b <=0[/code]

Peter Larsson
Helsingborg, Sweden
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2007-02-13 : 13:58:00
Got a link? I still don't buy it



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

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_laws

Should be required knowledge for anyone who ever writes a WHERE clause or does any computer programming ....


- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

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?

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2007-02-13 : 14:55:36
I got it...

Thanks



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page
   

- Advertisement -