Hi All,

I have a Date table in the database which has columns Date_id, yr_num, month_num, week_num. The Date Id has the values 2013-01-04, 2013-01-11, 2013-01-18, 2013-01-25, 2013-01-31, 2012-12-31, 2012-12-30.... I need to select a column which gives the prior Period of Date, Prior Year End. I am using Db2 as the database.

1. Get the Prior Period calculation. For the First period, it should give as zero (0) and for the remaining periods it should fetch the prior period.

2. Get the Prior Year End value (E.g. 2012-12-31 )


Date_ID Prior_date Prior_Year_end YR_num Mon_num
2013-01-04 0 2012-12-31 2013 1
2013-01-11 2013-01-04 2012-12-31 2013 1
2013-01-18 2013-01-11 2012-12-31 2013 1
2013-01-25 2013-01-18 2012-12-31 2013 1
2013-01-31 2013-01-25 2012-12-31 2013 1


Thanks in Advance.