
Untitled
By: a guest on
Apr 25th, 2012 | syntax:
None | size: 0.58 KB | hits: 12 | expires: Never
Oracle select months out of a timeframe
id from to
1 01.10.2011 28.02.2012
2 01.06.2008 30.09.2008
1 10 2011
1 11 2011
1 12 2011
1 01 2012
1 02 2012
2 06 2008
2 07 2008
2 08 2008
2 09 2008
select
id,
ADD_MONTHS( "from", N.N ),
to_char( dt_column, 'mm' ) ,
to_char( dt_column, 'yyyy' )
from
yourTable t
inner join
(SELECT ROWNUM n
FROM ( SELECT 1 just_a_column
FROM dual
CONNECT BY LEVEL <= 365
) N
on ADD_MONTHS( "from", N.N ) <= last_day( t."to" )