G
Guest
I have a query that is supposed to group results and sum totals of certain
fields. The sql from the query design window is below...
SELECT BeginningOfWeek([pcslog dos]) AS SundayDate, Employee![EMP Last Name]
& ", " & Employee![EMP First Name] & " " & Employee![EMP Middle Name] AS
EmployeeName, [CC PCS Billing Log].[PCSLOG-FK Emp ID], Sum([CC PCS Billing
Log].[PCSLOG Emp Hours]) AS [SumOfPCSLOG Emp Hours], Min([CC PCS Billing
Log].[PCSLOG Late Time]) AS [MinOfPCSLOG Late Time], Employee.[EMP-PK Emp ID]
FROM Employee INNER JOIN [CC PCS Billing Log] ON Employee.[EMP-PK Emp ID] =
[CC PCS Billing Log].[PCSLOG-FK Emp ID]
GROUP BY BeginningOfWeek([pcslog dos]), Employee![EMP Last Name] & ", " &
Employee![EMP First Name] & " " & Employee![EMP Middle Name], [CC PCS Billing
Log].[PCSLOG-FK Emp ID], Employee.[EMP-PK Emp ID]
HAVING (((Min([CC PCS Billing Log].[PCSLOG-FK Proc Code]))<>"A0080" And
(Min([CC PCS Billing Log].[PCSLOG-FK Proc Code]))<>"S0215" And (Min([CC PCS
Billing Log].[PCSLOG-FK Proc Code]))<>"Mi P Pay" And (Min([CC PCS Billing
Log].[PCSLOG-FK Proc Code]))<>"MI Super"))
ORDER BY BeginningOfWeek([pcslog dos]), Employee![EMP Last Name] & ", " &
Employee![EMP First Name] & " " & Employee![EMP Middle Name]
WITH OWNERACCESS OPTION;
a sub set of the results without the "totals" grouping is below i
substituted data for empname for privacy, but in this subset all employee
names are the same
SundayDate | EmployeeName | Employee | Emp Hours | Late Time | Employee ID
04/10/2005 | 7 | 7 | 1 |
No | 7
04/10/2005 | 7 | 7 | 5 |
No | 7
04/10/2005 | 7 | 7 | 5 |
No | 7
04/10/2005 | 7 | 7 | 5 |
No | 7
04/10/2005 | 7 | 7 | 4 |
No | 7
04/10/2005 | 7 | 7 | 1.25 |
No | 7
04/10/2005 | 7 | 7 | 2 |
No | 7
04/10/2005 | 7 | 7 | 2 |
No | 7
04/10/2005 | 7 | 7 | 2 |
No | 7
04/10/2005 | 7 | 7 | 3.5 |
No | 7
04/10/2005 | 7 | 7 | 4.75 |
No | 7
04/10/2005 | 7 | 7 | 2 |
No | 7
04/17/2005 | 7 | 7 | 2 |
No | 7
04/17/2005 | 7 | 7 | 1 |
Yes | 7
04/17/2005 | 7 | 7 | 4 |
Yes | 7
04/17/2005 | 7 | 7 | 4.75 |
Yes | 7
04/17/2005 | 7 | 7 | 1 |
No | 7
04/17/2005 | 7 | 7 | 2 |
No | 7
04/17/2005 | 7 | 7 | 2 |
No | 7
04/17/2005 | 7 | 7 | 5 |
No | 7
04/17/2005 | 7 | 7 | 5 |
No | 7
04/17/2005 | 7 | 7 | 5 |
No | 7
04/17/2005 | 7 | 7 | 2.25 |
No | 7
with the totals using the sql above this is the results of the data for that
employee
04/10/2005 | 7 | 7 | 37.5 |
0 | 7
which is correct for the 10th but the 17th is missing
the results should be the following
04/10/2005 | 7 | 7 | 37.5 |
0 | 7
04/17/2005 | 7 | 7 | 34 |
-1 | 7
what's wrong with my query?
fields. The sql from the query design window is below...
SELECT BeginningOfWeek([pcslog dos]) AS SundayDate, Employee![EMP Last Name]
& ", " & Employee![EMP First Name] & " " & Employee![EMP Middle Name] AS
EmployeeName, [CC PCS Billing Log].[PCSLOG-FK Emp ID], Sum([CC PCS Billing
Log].[PCSLOG Emp Hours]) AS [SumOfPCSLOG Emp Hours], Min([CC PCS Billing
Log].[PCSLOG Late Time]) AS [MinOfPCSLOG Late Time], Employee.[EMP-PK Emp ID]
FROM Employee INNER JOIN [CC PCS Billing Log] ON Employee.[EMP-PK Emp ID] =
[CC PCS Billing Log].[PCSLOG-FK Emp ID]
GROUP BY BeginningOfWeek([pcslog dos]), Employee![EMP Last Name] & ", " &
Employee![EMP First Name] & " " & Employee![EMP Middle Name], [CC PCS Billing
Log].[PCSLOG-FK Emp ID], Employee.[EMP-PK Emp ID]
HAVING (((Min([CC PCS Billing Log].[PCSLOG-FK Proc Code]))<>"A0080" And
(Min([CC PCS Billing Log].[PCSLOG-FK Proc Code]))<>"S0215" And (Min([CC PCS
Billing Log].[PCSLOG-FK Proc Code]))<>"Mi P Pay" And (Min([CC PCS Billing
Log].[PCSLOG-FK Proc Code]))<>"MI Super"))
ORDER BY BeginningOfWeek([pcslog dos]), Employee![EMP Last Name] & ", " &
Employee![EMP First Name] & " " & Employee![EMP Middle Name]
WITH OWNERACCESS OPTION;
a sub set of the results without the "totals" grouping is below i
substituted data for empname for privacy, but in this subset all employee
names are the same
SundayDate | EmployeeName | Employee | Emp Hours | Late Time | Employee ID
04/10/2005 | 7 | 7 | 1 |
No | 7
04/10/2005 | 7 | 7 | 5 |
No | 7
04/10/2005 | 7 | 7 | 5 |
No | 7
04/10/2005 | 7 | 7 | 5 |
No | 7
04/10/2005 | 7 | 7 | 4 |
No | 7
04/10/2005 | 7 | 7 | 1.25 |
No | 7
04/10/2005 | 7 | 7 | 2 |
No | 7
04/10/2005 | 7 | 7 | 2 |
No | 7
04/10/2005 | 7 | 7 | 2 |
No | 7
04/10/2005 | 7 | 7 | 3.5 |
No | 7
04/10/2005 | 7 | 7 | 4.75 |
No | 7
04/10/2005 | 7 | 7 | 2 |
No | 7
04/17/2005 | 7 | 7 | 2 |
No | 7
04/17/2005 | 7 | 7 | 1 |
Yes | 7
04/17/2005 | 7 | 7 | 4 |
Yes | 7
04/17/2005 | 7 | 7 | 4.75 |
Yes | 7
04/17/2005 | 7 | 7 | 1 |
No | 7
04/17/2005 | 7 | 7 | 2 |
No | 7
04/17/2005 | 7 | 7 | 2 |
No | 7
04/17/2005 | 7 | 7 | 5 |
No | 7
04/17/2005 | 7 | 7 | 5 |
No | 7
04/17/2005 | 7 | 7 | 5 |
No | 7
04/17/2005 | 7 | 7 | 2.25 |
No | 7
with the totals using the sql above this is the results of the data for that
employee
04/10/2005 | 7 | 7 | 37.5 |
0 | 7
which is correct for the 10th but the 17th is missing
the results should be the following
04/10/2005 | 7 | 7 | 37.5 |
0 | 7
04/17/2005 | 7 | 7 | 34 |
-1 | 7
what's wrong with my query?