SELECT ROWNUM,'1' AS FLAG
,(TO_DATE(TO_CHAR(DATE'2015-12-31','YYYY')||'-01-01','YYYY-MM-DD')+ ROWNUM - 1) AS DATE_DT
,DATE'2015-12-31' AS DATA_DATE
,SUBSTR(TO_CHAR((TO_DATE(TO_CHAR(DATE'2015-12-31','YYYY')||'-01-01','YYYY-MM-DD')+ ROWNUM - 1),'YYYY-MM-DD'),0,4) AS YEAR_0
FROM TOTAL
WHERE ROWNUM <= (TO_DATE(TO_NUMBER(TO_CHAR(DATE'2015-12-31','YYYY') )+ 1 || '-12-31','YYYY-MM-DD')-
TO_DATE(TO_CHAR(DATE'2015-12-31','YYYY') || '-01-01','YYYY-MM-DD')+1)
转载于:https://www.cnblogs.com/qadyyj/p/5435762.html