WITH T AS
(
SELECT TO_DATE('200811','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 7)
'Dev::DB > Oracle' 카테고리의 다른 글
ODP.NET 에서 Parameter 사용할 때.... (0) | 2014.11.26 |
---|---|
분할 조회 쿼리 (0) | 2013.12.03 |
START WITH ~ CONNECT BY ~ 에서 말단 Leaf (0) | 2012.07.24 |
Oracle 계층적 트리구조 START WITH ~ CONNECT BY ~ ORDER SIBLINGS BY (0) | 2010.01.18 |
ROW 를 COL 으로 변환 (0) | 2009.07.30 |