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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With