Simplifying and reducing the cost of an anti-join query

Posted by Savitha on Stack Overflow See other posts from Stack Overflow or by Savitha
Published on 2010-12-29T11:00:21Z Indexed on 2010/12/29 14:54 UTC
Read the original article Hit count: 293

Filed under:

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

© Stack Overflow or respective owner

Related posts about Oracle