WITH T AS (SELECT TO_DATE('201309', 'yyyymm') YM FROM DUAL) SELECT * FROM ( SELECT MIN(DECODE(TO_CHAR(YM + LEVEL - 1, 'D'), '1', LEVEL)) SUN , MIN(DECODE(TO_CHAR(YM + LEVEL - 1, 'D'), '2', LEVEL)) MON , MIN(DECODE(TO_CHAR(YM + LEVEL - 1, 'D'), '3', LEVEL)) TUE , MIN(DECODE(TO_CHAR(YM + LEVEL - 1, 'D'), '4', LEVEL)) WED , MIN(DECODE(TO_CHAR(YM + LEVEL - 1, 'D'), '5', LEVEL)) THU , MIN(DECODE(TO_CHAR(YM + LEVEL - 1, 'D'), '6', LEVEL)) FRI , MIN(DECODE(TO_CHAR(YM + LEVEL - 1, 'D'), '7', LEVEL)) SAT FROM T CONNECT BY LEVEL <= LAST_DAY(YM) - YM + 1 GROUP BY TRUNC(YM + LEVEL, 'IW') ORDER BY SAT )
0 Comments:
댓글 쓰기