Reputation: 3464
I've got table with following columns and data:
stock quant
----- -----
10 0
10 -5
10 1
1 20
10 1
10 88
5 1
What I need is to exclude rows with stock_status = 10
and quantity <= 0
at the same time.
I need to have those rows with stock_status = 10
but quantity > 0
or the other way around.
So the desire output from this would be
stock quant
---- ---
10 1
1 20
10 1
10 88
5 1
Thanks.
Upvotes: 3
Views: 3114
Reputation: 21004
Well you actually wrote the query yourself by telling us what you need to exclude...
SELECT stock, quant
FROM yourTable
WHERE NOT(stock_status = 10 AND quantity <= 0);
You should follow a tutorial on SQL query (for example on W3school) as this is very basic and you should be able to do a query like that in less than a minute after following a very short tutorial for beginner.
I recommend this link : SQL Tutorial.
Upvotes: 10
Reputation: 780673
SELECT stock, quant
FROM yourTable
WHERE NOT (stock_status = 10 AND quantity <= 0)
or, apply de Morgan's Laws:
SELECT stock, quant
FROM yourTable
WHERE stock_status != 10 OR quantity > 0
Upvotes: 3