All Forums Database
ratu 8 posts Joined 10/09
06 Jan 2010
Calendar table calculation

Hi All,I am a newbi to this forum so can someone help me out.I am trying to get past 6 month/year numbers from a calendar table in TD. For example I can query the calendar table on the current month and it will give me this….Yr Mo2010 01Now how can I write a query so that Results set should look like this:Yr Mo 2009 122009 112009 102009 092009 082009 07It should be a rolling looking back 6 months, such as when current month is:Yr Mo2010 04Results set should look like this:Yr Mo 2010 032010 022010 012009 122009 112009 10Can anyone please help!Thanks!

ravi.videla 21 posts Joined 09/09
06 Jan 2010

Hi Ratu,Please try below query. Hope this al1.year_of_calendar, al1.month_of_year from sys_calendar.CALENDAR al1, (select month_of_calendar from sys_calendar.CALENDAR where calendar_date = current_date) al2where al1.calendar_date < current_date and al1.month_of_calendar between al2.month_of_calendar-6 and al2.month_of_calendar-1group by 1,2 order by 1,2

You must sign in to leave a comment.