Simplifying and reducing the cost of an anti-join query
- by Savitha
Hi,
Could you please help me in simplifying and reducing the cost of the below query?
I tried making it a co-related subquery with NOT EXISTS but it didn't give me any output.
Please note that the table in both main and inner query is the same 'table_1".
SELECT *
FROM Table_1 A
WHERE A.Col1 = 'abcd'
AND (A.Col2, A.Col3) NOT IN
(SELECT Col2,
Col3
FROM Table_1 B
WHERE (B.Col4 IN (1,2,3)
And B.Col5 In ('x','y'))
OR (B.Col4 = 1 AND B.Col5 = 'z' AND B.Col6 = 'f')
))
Thanks in advance,
Savitha