July 1, 2010 at 10:02 pm
Hi Experts,
I am trying to get the moving average for the past 12 months in a simple fact table. (i.e. July 2010 => averages of past 11 months + current month)
I have a period column (200912, 201001, 201002, 201003, etc) and a value coumn containing figures.
200912 / 10
200912 / 12
200912 / 13
201001 / 12
.
.
.
etc
End results that I want to achieve is like this
period / Sales / Moving_average
200912 / 120 / 118
201001 / 150 / 140
201002 / 200 / 150
etc
could you please help,.
thanks alot
James
July 2, 2010 at 1:27 am
Please click the link in my signature to present your question in more helpfull way.
July 2, 2010 at 7:57 am
Please see the following article on this site:
Calculating Moving Averages with T-SQL[/url]
Paul White
SQLPerformance.com
SQLkiwi blog
@SQL_Kiwi
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply