WITH T1 AS (
SELECT '20141005' JOINDATE FROM DUAL
UNION ALL
SELECT '20140931' JOINDATE FROM DUAL
UNION ALL
SELECT '20140831' JOINDATE FROM DUAL
)
SELECT *
FROM T1
WHERE JOINDATE NOT IN (
SELECT to_char(to_date(MIN_JOINDATE,'yyyymmdd') + level - 1, 'yyyymmdd') dt
FROM (
SELECT MIN(JOINDATE) MIN_JOINDATE, MAX(JOINDATE) MAX_JOINDATE
FROM T1
) A
connect by level <= to_date(MAX_JOINDATE,'yyyymmdd') - to_date(MIN_JOINDATE,'yyyymmdd') + 1
)
이런식으로 날짜타입이 잘못들어간것을 찾으려니 너무 오래 걸리네요
혹시 좋은방법이 있을까요?
http://www.gurubee.net/article/41514
댓글에 사용자함수 쓰는방법있어요..
WITH T1 AS (
SELECT '20141005' JOINDATE FROM DUAL
UNION ALL
SELECT '20140931' JOINDATE FROM DUAL
UNION ALL
SELECT '20140831' JOINDATE FROM DUAL
UNION ALL
SELECT '20120229' JOINDATE FROM DUAL
UNION ALL
SELECT '20130229' JOINDATE FROM DUAL
UNION ALL
SELECT '20140229' JOINDATE FROM DUAL
UNION ALL
SELECT '20140800' JOINDATE FROM DUAL
)
SELECT
JOINDATE,FIRST_DAY,LAST_DAY
,CASE WHEN JOINDATE BETWEEN FIRST_DAY AND LAST_DAY THEN 'A' ELSE 'B' END FLAG
FROM (
SELECT
JOINDATE
,TO_CHAR(TO_DATE(SUBSTR(JOINDATE,1,6),'YYYYMM'),'YYYYMMDD') FIRST_DAY
,TO_CHAR(LAST_DAY(TO_DATE(SUBSTR(JOINDATE,1,6),'YYYYMM')),'YYYYMMDD') LAST_DAY
FROM T1
)
;