I have following data in my input sql server 2005 database table:
a) Agreed date
b) End date
c) Frequency - Monthly/Weekly
d) Number of payments
Ex: When agreed date = 7/1/2009, Frequency is Monthly, and Number of Payments is 4, it indicates that 4 future payments are expected and they are on: 7/1/2009, 8/1/2009, 9/1/2009 and 10/10/2009 (which is the End date also).
I need to aggregate this data into a report having:
X axis - Months (from current month to 12 months)
Y axis - Current month dates.
My sample input data and output report are attached here. How can I achieve this in a stored procedure in Sql Server 2005?