I have a table in SQL Server 2005 database that has following columns:
Id,ProductName,Year,Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec
What I need to do is to calculate an average ROLLING value for a product.
For instance, if product named “Car” has 2 rows in a table(Year 2009 and 2010) I want to calculate average values from August 2009 to August 2010 or March 2009 to March 2010.
What is the best way to accomplish this?
Using Sql Server 2005, you can have a look at the UNPIVOT.
Once you have them back into rows where they belong, you can start playing around with the data.
Something like