If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
moving averages
I have the following data and I would like to calculate moving average for 3
years to know overall impact on food price year price 2001 450 2002 465 2003 470 2004 478 2005 495 2006 484 2007 499 please help me |
#2
|
|||
|
|||
moving averages
Try this --
SELECT [Year], (SELECT Sum([XX].[Price])/3 FROM YourTable AS [XX] WHERE [XX].[Year] Between [YourTable].[Year] AND [YourTable].[Year]-3) AS [3 Year Average] FROM [YourTable] GROUP BY [Year]'; You should not use Year as it is a reserved word and may cause problems. -- Build a little, test a little. "cliff" wrote: I have the following data and I would like to calculate moving average for 3 years to know overall impact on food price year price 2001 450 2002 465 2003 470 2004 478 2005 495 2006 484 2007 499 please help me |
Thread Tools | |
Display Modes | |
|
|