Sum on Head Count data wrong

  • Thread starter Thread starter albert.repasky
  • Start date Start date
A

albert.repasky

I am trying to sum the fldHC, but it takes the field Planned as a
separate number and gives me 2 records and does not sum them. I just
can not see what I am doing wrong. I want to sum the Head Count if the
date is the same, the group is the same, the SAID is the same, and the
Location is the same. There are 2 Cost Codes for one SAID with
different Head Counts, so I does not add them to gether. I do not
select the Cost Code field, so why does it not sum up the fldHC?

Let me know if you need more info.

Thanks ahead of time.
Arep

SELECT tblHeadCount.fldMonthYear, tblSAID.fldGroup,
tblHeadCount.fldSAID, tblHeadCount.fldLocation,
Sum(tblHeadCount.fldHC) AS Planned
FROM tblSAID RIGHT JOIN tblHeadCount ON tblSAID.fldSAID =
tblHeadCount.fldSAID
GROUP BY tblHeadCount.fldMonthYear, tblSAID.fldGroup,
tblHeadCount.fldSAID, tblHeadCount.fldLocation, tblHeadCount.fldHC
HAVING (((tblHeadCount.fldHC)>0))
ORDER BY tblHeadCount.fldMonthYear, tblSAID.fldGroup,
tblHeadCount.fldSAID, tblHeadCount.fldLocation;
 
I am trying to sum the fldHC, but it takes the field Planned as a
separate number and gives me 2 records and does not sum them. I just
can not see what I am doing wrong. I want to sum the Head Count if the
date is the same, the group is the same, the SAID is the same, and the
Location is the same. There are 2 Cost Codes for one SAID with
different Head Counts, so I does not add them to gether. I do not
select the Cost Code field, so why does it not sum up the fldHC?

Let me know if you need more info.

Thanks ahead of time.
Arep

SELECT tblHeadCount.fldMonthYear, tblSAID.fldGroup,
tblHeadCount.fldSAID, tblHeadCount.fldLocation,
Sum(tblHeadCount.fldHC) AS Planned
FROM tblSAID RIGHT JOIN tblHeadCount ON tblSAID.fldSAID =
tblHeadCount.fldSAID
GROUP BY tblHeadCount.fldMonthYear, tblSAID.fldGroup,
tblHeadCount.fldSAID, tblHeadCount.fldLocation, tblHeadCount.fldHC
HAVING (((tblHeadCount.fldHC)>0))
ORDER BY tblHeadCount.fldMonthYear, tblSAID.fldGroup,
tblHeadCount.fldSAID, tblHeadCount.fldLocation;

I solved the problem. What I had to do was create another query.
That query just collects the 5 fields without doing the summing. Then
the next query does the summing of the fldHC. The 2 things had to be
separated.

Arep
 
Back
Top