I have a table something like this.
count | date ------------------ 1 2012-01-01 4 2012-01-01 5 2012-01-02 12 2012-01-03 7 2012-01-04 4 2012-01-05 19 2012-01-06 1 2012-01-07 etc...
I'm looking for a way to calculate the average count per week over the previous 4 week period for each week.
The results should be something like...
avg | yearweek ------------------ 3 201201 5 201202 6 201203 1 201204 11 201205 3 201206 18 201207 12 201208 etc...
...where each yearweek is the weekly average over the past 4 yearweeks.
Getting the weekly averages is simple enough but how do I then get that over the past 4 yearweeks? And then how to do I do that as a rolling average? Am I better off just doing this in code?