WITH T1 ( A ) AS ( SELECT '111' FROM DUAL UNION ALL SELECT '222' FROM DUAL UNION ALL SELECT '333' FROM DUAL ), T2 ( B , C ) AS ( SELECT 'test1' , '111' FROM DUAL UNION ALL SELECT 'test1' , '222' FROM DUAL UNION ALL SELECT 'test1' , '333' FROM DUAL UNION ALL SELECT 'test2' , '111' FROM DUAL UNION ALL SELECT 'test2' , '222' FROM DUAL ) SELECT tt2.B , T1.A FROM T1 , (SELECT B FROM T2 GROUP BY B ) tt2 WHERE ( B , A ) NOT IN ( SELECT B , C FROM T2 ) ORDER BY B , A
--또 다른 방법으로는 --효율은... 별로임.. ㅋㅋ WITH 테이블1 AS ( SELECT 111 D FROM DUAL UNION ALL SELECT 222 FROM DUAL UNION ALL SELECT 333 FROM DUAL ), 테이블2 AS ( SELECT 'test1' F, 111 D FROM DUAL UNION ALL SELECT 'test1', 222 FROM DUAL UNION ALL SELECT 'test1', 333 FROM DUAL UNION ALL SELECT 'test2', 111 FROM DUAL UNION ALL SELECT 'test2', 222 FROM DUAL ) SELECT 테이블2.F, 테이블1.D FROM 테이블1, (SELECT F FROM 테이블2 GROUP BY F) 테이블2 MINUS SELECT F, D FROM 테이블2