Help - calculating averages

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to calculate the average earnings for employees for the last five
years of their employment. The table I'm working with looks like this:

employee # begin_date end_date earnings
sam 1/1/2004 12/31/2004 $35000
sam 1/1/2003 12/31/2003 $27,500

and so on. Can someone please help me design the query? Thanks!
 
Try this
SELECT EmployeeTable.[employee id], Avg(EmployeeTable.earnings) AS Avgearnings
FROM EmployeeTable
WHERE
(((EmployeeTable.begin_date)>=DateSerial(Year(DateAdd("yyyy",-5,Date())),1,1)))
GROUP BY EmployeeTable.[employee id]

Moving back to the 1/1 5 years from today.
No consideration if the employee started working in the middle of the year
You need to change the name of the table
 
Back
Top