WITH t1 AS ( SELECT 10 seqno, '20231010' dt FROM dual UNION ALL SELECT 20, '20231111' FROM dual ) , t2 AS ( SELECT 10 seqno, 100 cnt FROM dual UNION ALL SELECT 30, 200 FROM dual ) SELECT seqno , MIN(dt) dt , MIN(cnt) cnt FROM (SELECT seqno, dt, null cnt FROM t1 UNION ALL SELECT seqno, null dt, cnt FROM t2 ) WHERE seqno = 30 GROUP BY seqno ;
WITH t1 AS ( SELECT 10 seqno, '20231010' dt FROM dual UNION ALL SELECT 20, '20231111' FROM dual ) , t2 AS ( SELECT 10 seqno, 100 cnt FROM dual UNION ALL SELECT 30, 200 FROM dual ) SELECT NVL(a.seqno, b.seqno) seqno , a.dt , b.cnt FROM (SELECT * FROM t1 WHERE seqno = :v_seqno) a FULL OUTER JOIN (SELECT * FROM t2 WHERE seqno = :v_seqno) b ON a.seqno = b.seqno ;