sqlserver:
select convert(varchar(7),dateadd(mm,-t.number,getdate()),120)
from
(select number from master..spt_values where type='P') t
where year(dateadd(mm,-t.number,getdate()))=year(getdate())
order by convert(varchar(7),dateadd(mm,-t.number,getdate()),120)
oracle:
select to_char(add_months(sysdate, -t.rn), 'yyyy-mm')
from dual a, (select rownum - 1 rn from dual connect by rownum <= 12) t
where to_char(add_months(sysdate, -t.rn), 'yyyy') =
to_char(sysdate, 'yyyy')
order by to_char(add_months(sysdate, -t.rn), 'yyyy-mm')