Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Moving Average 1

Status
Not open for further replies.

VC2002

Technical User
Nov 15, 2002
34
IE
Hi!

I realise this is probably a simple question, but I cant get to grips with it!

I have a table containing two fields - price and data. I wish to run a query that will contain the two fields mentioned and a field that will calculate the average price for the previous 15 days, up-to and including the most recent date.

As more records are added, the query should update the moving average.

Is this possible and how?

Thanks a lot!
 
make a query like:

Code:
SELECT Avg(price) FROM yourTableName WHERE DateDiff('d',data,now)<=15;

with the right table and field names.

Best regards
 
Sorry, but with the following expression, what should go in the 'data' and 'now' parts?


WHERE DateDiff('d',data,now)<=15;

 
Code:
data
is the field containing the date and
Code:
now
is a built-in function that returns the current date and time. The
Code:
'd'
says that you want the difference in days.

Best regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top