Help - calculating averages

A

A

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!
 
O

Ofer

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
 

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

Top