갑자기 OUT JOIN이 제 생각대로 안되네요. 뭐가 잘못된걸까요? 전 아래 결과가 ORG=B,C,D 만 나오게 하고 싶은데..안되네요. 즉, V_DATE 에 없는 조직이나, DT >='오늘일자'보다 큰 조직만 나오게 하고 싶습니다. 미리 감사드립니다. WITH V_CODE AS ( SELECT 'A' ORG FROM DUAL UNION ALL SELECT 'B' ORG FROM DUAL UNION ALL SELECT 'C' ORG FROM DUAL UNION ALL SELECT 'D' ORG FROM DUAL ),V_DATE AS ( SELECT 'A' ORG, '20190901' DT FROM DUAL UNION ALL SELECT 'B' ORG, '20191011' DT FROM DUAL UNION ALL SELECT 'C' ORG, '20201111' DT FROM DUAL ) SELECT C.*, D.DT FROM V_CODE C , V_DATE D WHERE C.ORG = D.ORG (+) AND D.DT(+) >= TO_CHAR(SYSDATE, 'YYYYMMDD') ;
WITH V_CODE AS ( SELECT 'A' ORG FROM DUAL UNION ALL SELECT 'B' ORG FROM DUAL UNION ALL SELECT 'C' ORG FROM DUAL UNION ALL SELECT 'D' ORG FROM DUAL ),V_DATE AS ( SELECT 'A' ORG, '20190901' DT FROM DUAL UNION ALL SELECT 'B' ORG, '20191011' DT FROM DUAL UNION ALL SELECT 'C' ORG, '20201111' DT FROM DUAL ) SELECT C.*, D.DT FROM V_CODE C , V_DATE D WHERE C.ORG = D.ORG (+) AND NVL(D.DT,TO_CHAR(SYSDATE, 'YYYYMMDD')) >= TO_CHAR(SYSDATE, 'YYYYMMDD') ;