Question about "averages" (1 Viewer)

PvL

New member
Local time
Today, 07:49
Joined
Jul 4, 2008
Messages
6
Hi guys

If I have a table containing fields:
- employee
- date
- amount of jobs

As different employees work different days and have occasionally off days of course, how would I make a query with the result of a list of the employees and the average amounts of jobs per day?

Guess this is an easy one for you gurus, but I just cant get it to work.
Many thanks for the forthcoming answer(s) :)
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 23:49
Joined
Oct 29, 2018
Messages
21,447
Hi. Are you able to post some sample data?
 

Mark_

Longboard on the internet
Local time
Yesterday, 23:49
Joined
Sep 12, 2017
Messages
2,111
You can use DCount for this, depending on how often you need to do this.

WorkDays = DCount("[Table that holds the days your employee works]", "Field", [Employee Work Day] & " Between " & [Start date] & " AND " & [End Date] )
WorkJobs = DCount("[Table that holds the Jobs your employee works]", "Field", [Job Day] & " Between " & [Start date] & " AND " & [End Date] )

AverageJobs = WorkJobs/WorkDays

If this is going to be for multiple employees you can do SUM queries for each and join them to a query on employees. You'd then have an expression that does your calculation.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 14:49
Joined
May 7, 2009
Messages
19,226
same as above:
Code:
SELECT DISTINCT employee, 
(SELECT SUM([amount of jobs]) 
FROM yourTableName AS T WHERE T.employee=yourTableName.employee)/
(SELECT COUNT("1") FROM yourTableName AS T WHERE T.employee = yourTableName.employee) 
As AvgJobPerDay FROM yourTableName;
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 02:49
Joined
Feb 19, 2002
Messages
43,196
Select Employee, Avg(Jobs) As AvgJobs From YourTable;
 

Users who are viewing this thread

Top Bottom