select substr(S1.DATE2021, 1, 6) AS MONTH2021,
TO_CHAR(LAST_DAY(TO_DATE(S1.DATE2021)), 'DD') AS LAST_DAY
FROM (
SELECT '20210101' AS DATE2021 FROM DUAL UNION ALL
SELECT '20210201' AS DATE2021 FROM DUAL UNION ALL
SELECT '20210301' AS DATE2021 FROM DUAL UNION ALL
SELECT '20210401' AS DATE2021 FROM DUAL UNION ALL
SELECT '20210501' AS DATE2021 FROM DUAL UNION ALL
SELECT '20210601' AS DATE2021 FROM DUAL UNION ALL
SELECT '20210701' AS DATE2021 FROM DUAL UNION ALL
SELECT '20210801' AS DATE2021 FROM DUAL UNION ALL
SELECT '20210901' AS DATE2021 FROM DUAL UNION ALL
SELECT '20211001' AS DATE2021 FROM DUAL UNION ALL
SELECT '20211101' AS DATE2021 FROM DUAL UNION ALL
SELECT '20211201' AS DATE2021 FROM DUAL
) S1;
LAST_DAY() 함수는 특정월의 마지막 날을 구함
'스터디 > Oracle' 카테고리의 다른 글
[Oracle/오라클] ROLLUP 소계 / 총계 표현하기 (0) | 2021.07.16 |
---|---|
[Oracle/오라클] ADD_MONTHS, MONTH_BETWEEN (0) | 2021.07.11 |
[Oracle / 오라클] Sub Query 서브쿼리 예제 (0) | 2021.05.31 |
[Oracle / 오라클] 누적합계를 UPDATE 하기 (0) | 2021.05.31 |
[Oracle / 오라클] INSERT ALL, WHEN으로 조건별 다중 테이블에 일괄 INSERT 시키기 (0) | 2021.05.08 |