moving averages

C

cliff

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
 
K

KARL DEWEY

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top