I currently have data stored as follows:
PERSON DATE RATE
----------------------------
John Smith 1/4/2012 1.2
John Smith 8/6/2012 1.7
John Smith 8/13/2012 1.9
John Smith 8/20/2012 2
John Smith 9/10/2012 1.8
John Smith 10/1/2012 3
I’m trying to output a rate for each week (ending Sunday) of the year for each person. Where the rate doesn’t exist for a given week, the previous week is used i.e.:
PERSON WEEK RATE
----------------------------
John Smith 1/8/2012 1.2
John Smith 1/15/2012 1.2
John Smith 1/22/2012 1.2
John Smith 1/29/2012 1.2
etc
I can build a table of for date and week combinations so I can determine the week. How can I duplicate the rate though? An outer join or something similar?
There’s a lot I don’t know about your data, but here’s a suggestion. The first subquery selects all distinct persons, the second matches each of these to each week (supposing you store weeks as date and 00:00 am Sunday morning). This supposes that Person is unique, but I hope you have a primary key that can be used to determine who’s who.