sql_learner sql_learner - 1 month ago 8
SQL Question

how to get previous 11 month names from sysdate using oracle

how to get previous 11 month names from sysdate using oracle

i tried like , iam getting month names between some dates

select add_months (trunc (to_date('10/18/2007','MM/DD/YYYY'), 'MM'), 1*Level -1)
Month FROM Dual
CONNECT BY Level <= MONTHS_BETWEEN(to_date('11/17/2008','MM/DD/YYYY'), to_date('10/18/2007','MM/DD/YYYY')) + 1
order by month

Answer

May be you need something like that:

select to_char(add_months (to_date('10/18/2007','MM/DD/YYYY'), -1* Level), 'Mon-YYYY')
Month   
FROM Dual
CONNECT BY Level <= 11
order by month
Comments