-----Original Message-----
TRY The following UNTESTED SQL statements. I think they will work
Daily Average for each employee
SELECT [StaffId], Avg([Hours]) as AvgDaily Hours
FROM YourTable
WHERE [Date] Between [SomeStartDate] and [SomeEndDate]
GROUP BY [StaffID]
Weekly Average for Each Employee is a bit more complex.
Save following as qryOne:
SELECT [StaffId],
DateAdd("d",1-Weekday([Date]),[Date]) as WeekStart,
Sum(Hours) as TotalHours
FROM YourTable
WHERE [Date] Between [SomeStartDate] and [SomeEndDate]
GROUP BY StaffID, DateAdd("d",1-Weekday([Date]),[Date])
Use qryOne as source for qryTwo:
SELECT StaffID, Sum(TotalHours)/Count(WeekStart) as WeekAvg
FROM qryOne
GROUP BY StaffID
Sorry for being so terse. Let's try that again. The data
is held in the table StaffHours. It contains the following
fields: StaffID, Date, Hours. (There's a projectID and
other whatnot, but that's not important here.
So a given record would cover who (StaffID), worked
on what day (Date), how many hours (Hours).
It doesn't really matter what they worked on. It's
more about how to average out the number hours they tend
to work in a week.
The underlying point is this: One department has a
number of different employees, some working full time,
part time and three- quarters time. They may also switch
back and forth, with more time or less.
Their vacation days are compensated by an average of
how much they've worked in the past six months. The
managers want a weekly average (for vacation pay) and a
daily average (for personal days).
It's easy to find the overall average; the question is
how to break out the week timeframe.
The results can be in a report or a query, either
way. Thanks-- Harry
Hours
record - the number of want
this by project by employee?
.