연도별분기별
-
[오라클] 지정기간의 모든 연도별 분기를 가져오는 쿼리IT탐구생활/오라클 2023. 6. 26. 19:43
WITH WD AS ( SELECT TO_DATE(:SMT, 'YYYY-MM') AS FROM_DT , TO_DATE(:EMT, 'YYYY-MM') AS TO_DT FROM DUAL ) SELECT :COM_CD COM_CD, YEAR,QUARTER FROM ( SELECT TO_CHAR(ADD_MONTHS(FROM_DT , (LEVEL-1)), 'YYYY') YEAR , TO_CHAR(ADD_MONTHS(FROM_DT , (LEVEL-1)), 'Q') QUARTER FROM WD CONNECT BY LEVEL