SELECT
T1.YYYYMM,
T1.DD,
TO_CHAR(TO_DATE(T1.YYYYMM||T1.DD,'YYYYMMDD'),'D') WEEK
FROM
(
SELECT
TO_CHAR(TO_DATE(C2.PRE0101,'YYYYMMDD') + (ROWNUM-1),'YYYYMM') YYYYMM,
TO_CHAR(TO_DATE(C2.PRE0101,'YYYYMMDD') + (ROWNUM-1),'DD') DD
FROM
INT_TMP_NUMBER C1,
(
SELECT
TO_CHAR(SYSDATE,'YYYY')-1||'0101' PRE0101,
TO_CHAR(SYSDATE,'YYYY')-1||'1231' PRE1231,
TO_CHAR(SYSDATE,'YYYY')||'1231' THIS1231
FROM
DUAL
) C2
WHERE
SEQ BETWEEN 1 AND TO_CHAR(TO_DATE(C2.PRE1231,'YYYYMMDD'),'DDD') + TO_CHAR(TO_DATE(C2.THIS1231,'YYYYMMDD'),'DDD')
) T1
WHERE
T1.YYYYMM >= TO_CHAR(ADD_MONTHS(SYSDATE,-2),'YYYYMM')
AND T1.YYYYMM <= TO_CHAR(SYSDATE,'YYYYMM')