반응형
--일정보
SELECT MONTH
FROM (SELECT DAY1 + LEVEL -1 MONTH
FROM (SELECT TO_DATE('20070101', 'YYYYMMDD') DAY1 ,TO_DATE('20070103', 'YYYYMMDDHH') day2
FROM DUAL)
CONNECT BY LEVEL <= DAY2 - DAY1 + 1);
--월정보
SELECT TO_CHAR(MONTH , 'YYYYMM')
FROM (SELECT ADD_MONTHS(DAY1, (LEVEL -1)) AS MONTH
FROM (SELECT TO_DATE('200611', 'YYYYMM') DAY1
,TO_DATE('200709', 'YYYYMM') DAY2
FROM DUAL)
CONNECT BY LEVEL <= ABS(MONTHS_BETWEEN(DAY1, DAY2 )) + 1
);
반응형