Stang70Fastback
Registered User.
- Local time
- Yesterday, 21:30
- Joined
- Dec 24, 2012
- Messages
- 132
Need Help with Summing Query (SOLVED!)
Hello again! Another question, since you were so helpful with the last one:
I have four columns: Employee, Discipline, AvailableHours, TotalHours.
I want to summarize these by Discipline, so that for a list of employees, I wind up with a list of the various disciplines, with the TotalHours per discipline. HOWEVER, the available hours should be summed, but only adding ONE for each employee. It's hard to explain, so hopefully the example below makes more sense:
DATA
John - Architect - 40 - 10
Mary - Architect - 40 - 10
John - Architect - 40 - 20
Mary - Architect - 40 - 30
John - Architect - 40 - 10
Bill - Plumber - 40 - 10
DESIRED RESULT
Architect - 80 - 80
Plumber - 40 - 10
Notice that it is summing the last column, but only summing the third column for ONE entry for each unique individual. That's because each record contains the working hours the employee can work (40 hours), along with the hours they've been assigned for THAT record. So I want to sum all of their assigned hours, but obviously the hours they CAN work stays the same. They don't work a 40 hour work week for EACH job they are assigned to, if that makes sense.
My current query sums BOTH columns completely, so it falsely states that there are 200 available working hours between the two architectural employees, when there are only 80 hours between the two. My current query is:
So I'm wondering if there is any way to sum the AvailableHours column but tell the system to only count each employee once.
Hello again! Another question, since you were so helpful with the last one:
I have four columns: Employee, Discipline, AvailableHours, TotalHours.
I want to summarize these by Discipline, so that for a list of employees, I wind up with a list of the various disciplines, with the TotalHours per discipline. HOWEVER, the available hours should be summed, but only adding ONE for each employee. It's hard to explain, so hopefully the example below makes more sense:
DATA
John - Architect - 40 - 10
Mary - Architect - 40 - 10
John - Architect - 40 - 20
Mary - Architect - 40 - 30
John - Architect - 40 - 10
Bill - Plumber - 40 - 10
DESIRED RESULT
Architect - 80 - 80
Plumber - 40 - 10
Notice that it is summing the last column, but only summing the third column for ONE entry for each unique individual. That's because each record contains the working hours the employee can work (40 hours), along with the hours they've been assigned for THAT record. So I want to sum all of their assigned hours, but obviously the hours they CAN work stays the same. They don't work a 40 hour work week for EACH job they are assigned to, if that makes sense.
My current query sums BOTH columns completely, so it falsely states that there are 200 available working hours between the two architectural employees, when there are only 80 hours between the two. My current query is:
Code:
SELECT Discipline, Sum(ManpowerData.AvailableHours) As AvailableHours, Sum(ManpowerData.TotalHours) As TotalHours
FROM ManpowerData
GROUP BY Discipline;
So I'm wondering if there is any way to sum the AvailableHours column but tell the system to only count each employee once.
Last edited: