I am trying to find out unique rows from the given data
In my case I am storing buy sell of the stock in stock table. So same client can buy sell same stock.
So ask is to just fetch stocks which are only BUY and not SELL by any other client.
Here is the sqlFiddle link where I have shared table structure and query I tried
http://sqlfiddle.com/#!9/df117d/2
I am expecting result as –
STOCKB
STOCKD
STOCKE
>Solution :
You can do:
SELECT DISTINCT s.symbol
FROM bulk s
WHERE s.buy_sell='BUY' AND 'SELL' not in (
SELECT a.buy_sell
FROM bulk a
WHERE a.symbol = s.symbol AND a.buy_sell='SELL'
)
See SQLFiddle