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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Advanced Averaging.....

Status
Not open for further replies.

fenneraj

Programmer
Jul 29, 2003
21
SE
Hi,
I would like to be able to calculate averages for the last 50 records in my database only.

Using the statement:
SELECT AVG(qu1Radio) AS qu1AVG..........

This takes an average of all 1100 records. Could it be done by providing arguments directly to the AVG clause or by using WHERE statements, if so how can this be done.

I thank you all for your help in advance.

Regards
Andrew Fenner
 
You can use a SUBQUERY in the WHERE clause to accomplish this:
Code:
SELECT AVG(qu1Radio) AS qu1AVG
FROM table
WHERE UpdateDate IN (SELECT TOP 50 UpdateDate FROM table ORDER BY UpdateDate DESC)

~Brian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top