with t as
(select rownum - 1 rn from dual connect by rownum <= 1000)
select to_char(add_months(trunc(sysdate), -rn), 'yyyy-mm')
from t
where to_char(add_months(trunc(sysdate), -rn), 'yyyy') between 2017 and 2018
order by to_char(add_months(trunc(sysdate), -rn), 'yyyy-mm')
结果:
修改语句中2017和2018的地方就行,最大支持查询1000行数据,要是再多的话,修改语句第二行<=1000的那个位置。