标签:
今天做一个统计报表的时候正好碰到这个问题,原来,一般是通过后台代码来生成。现在直接通过oracle来生成,记录一下。
方法一: SELECT YEAR FROM ( SELECT TO_CHAR(SYSDATE-ROWNUM*365,‘YYYY‘) YEAR FROM DUAL CONNECT BY ROWNUM<65 UNION SELECT TO_CHAR(SYSDATE,‘YYYY‘) YEAR FROM DUAL )ORDER BY YEAR DESC; 方法二: SELECT YEAR FROM ( SELECT TO_CHAR(SYSDATE-ROWNUM*365,‘YYYY‘) YEAR FROM DUAL CONNECT BY LEVEL<10 UNION SELECT TO_CHAR(SYSDATE,‘YYYY‘) YEAR FROM DUAL )ORDER BY YEAR DESC;
标签:
原文地址:http://www.cnblogs.com/Yang2012/p/4218450.html