A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

moving averages



 
 
Thread Tools Display Modes
  #1  
Old December 18th, 2009, 02:01 AM posted to microsoft.public.access.queries
Cliff
external usenet poster
 
Posts: 136
Default 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  
Old December 18th, 2009, 05:31 AM posted to microsoft.public.access.queries
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:58 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.