WITH a AS ( SELECT 'A0001' cd, 1 v FROM dual UNION ALL SELECT 'B0001', 2 FROM dual UNION ALL SELECT 'C0001', 3 FROM dual ) , b AS ( SELECT 'A0001' cd, 5 v FROM dual UNION ALL SELECT 'D0001', 6 FROM dual UNION ALL SELECT 'E0001', 7 FROM dual ) SELECT a.* FROM a, b WHERE a.cd = b.cd(+) AND a.v > NVL(b.v, 0) ;