첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
유용한 소스 코드가 있으면 icodebroker@naver.com으로 보내주시면 감사합니다.
블로그 자료는 자유롭게 사용하세요.

■ 해당 월 달력 조회하기

------------------------------------------------------------------------------------------------------------------------

SELECT

    CASE WHEN (LEVEL * 7 - 6 - WEEK) BETWEEN 1 AND LAST THEN TO_CHAR(LEVEL * 7 - 6 - WEEK) ELSE '' END AS 일

   ,CASE WHEN (LEVEL * 7 - 5 - WEEK) BETWEEN 1 AND LAST THEN TO_CHAR(LEVEL * 7 - 5 - WEEK) ELSE '' END AS 월

   ,CASE WHEN (LEVEL * 7 - 4 - WEEK) BETWEEN 1 AND LAST THEN TO_CHAR(LEVEL * 7 - 4 - WEEK) ELSE '' END AS 화

   ,CASE WHEN (LEVEL * 7 - 3 - WEEK) BETWEEN 1 AND LAST THEN TO_CHAR(LEVEL * 7 - 3 - WEEK) ELSE '' END AS 수

   ,CASE WHEN (LEVEL * 7 - 2 - WEEK) BETWEEN 1 AND LAST THEN TO_CHAR(LEVEL * 7 - 2 - WEEK) ELSE '' END AS 목

   ,CASE WHEN (LEVEL * 7 - 1 - WEEK) BETWEEN 1 AND LAST THEN TO_CHAR(LEVEL * 7 - 1 - WEEK) ELSE '' END AS 금

   ,CASE WHEN (LEVEL * 7 - 0 - WEEK) BETWEEN 1 AND LAST THEN TO_CHAR(LEVEL * 7 - 0 - WEEK) ELSE '' END AS 토

FROM DUAL

    ,(SELECT TO_CHAR(LAST_DAY(TO_DATE('202002', 'YYYYMM')), 'DD') AS LAST FROM DUAL)

    ,(SELECT TO_CHAR(TO_DATE('202002', 'YYYYMM'), 'D') - 1 AS WEEK FROM DUAL)

CONNECT BY LEVEL <= CEIL((WEEK + LAST) / 7);

------------------------------------------------------------------------------------------------------------------------

Posted by 사용자 icodebroker

댓글을 달아 주세요