SQL Challenge, not sure if it can be done?
Posted on 2005-05-05
I have been requested by my boss to create a report and Im not sure if I can do the SQL to genrerate the data. I don't really want to 'launder' the data through excel etc..
I wont give you the exact layout of the tables as it is beyond the scope but an example will suffice.
There is data going on by week for 2 years. What my boss wants is a 52 week moving average. So for a given starting date the database will calculate the average for Week 8/4/05 to 8/4/04, Week 1/4/05 to 1/4/04, 24/4/05 to 24/4/04 and so on. That way you get 52 figures that represent a trend over the last 52 weeks.
How can I do that in SQL?
Feel free to ask me more questions, any help is always appreciated!