A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Sum Query



 
 
Thread Tools Display Modes
  #1  
Old July 21st, 2008, 02:48 AM posted to microsoft.public.access.queries
Ernst Guckel
external usenet poster
 
Posts: 50
Default Sum Query

Hello,

I am trying to sum all hours worked per employee within a given week. I
want the total of EmpHours and EmpOTHours between Date1 and Date2 Here is
what I have but of cource it doesnt work right...

SELECT DISTINCTROW tblEmployees.EmpLast & ", " & [EmpFirst] AS FirstLast,
Format$(tblEmpPayroll.EmpPayDate,'Long Date') AS [EmpPayDate By Day],
Sum(tblEmpPayroll.EmpHours) AS [Sum Of EmpHours],
Sum(tblEmpPayroll.EmpOTHours) AS [Sum Of EmpOTHours]
FROM tblEmployees INNER JOIN tblEmpPayroll ON tblEmployees.EmpFileNumber =
tblEmpPayroll.EmpNumber
GROUP BY tblEmployees.EmpLast & ", " & [EmpFirst],
Format$(tblEmpPayroll.EmpPayDate,'Long Date'), tblEmployees.EmpFirst,
tblEmpPayroll.EmpNumber
HAVING (((Format$([tblEmpPayroll].[EmpPayDate],'Long Date')) Between
Format(Date()-Weekday(Date()),"\#mm/dd/yyyy\#") And
Format(Date()-Weekday(Date())-7,"\#mm/dd/yyyy\#")));


Thanks,
Ernst.

  #2  
Old July 21st, 2008, 12:24 PM posted to microsoft.public.access.queries
John Spencer
external usenet poster
 
Posts: 2,364
Default Sum Query

PERHAPS something like the following. Although without knowing your
table structure (tblEmpPayroll) and what data is actually stored in the
table this is a guess.

SELECT tblEmployees.EmpLast & ", " & [EmpFirst] AS FirstLast,
Format$(tblEmpPayroll.EmpPayDate,'Long Date') AS [EmpPayDate By Day],
Sum(tblEmpPayroll.EmpHours) AS [Sum Of EmpHours],
Sum(tblEmpPayroll.EmpOTHours) AS [Sum Of EmpOTHours]
FROM tblEmployees INNER JOIN tblEmpPayroll
ON tblEmployees.EmpFileNumber = tblEmpPayroll.EmpNumber
GROUP BY tblEmployees.EmpLast & ", " & [EmpFirst],
Format$(tblEmpPayroll.EmpPayDate,'Long Date')
, tblEmployees.EmpFirst,
tblEmpPayroll.EmpNumber
WHERE [tblEmpPayroll].[EmpPayDate] Between
Date()-Weekday(Date())
And Date()-Weekday(Date())-7


'================================================= ===
John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
'================================================= ===


Ernst Guckel wrote:
Hello,

I am trying to sum all hours worked per employee within a given week. I
want the total of EmpHours and EmpOTHours between Date1 and Date2 Here is
what I have but of cource it doesnt work right...

SELECT DISTINCTROW tblEmployees.EmpLast & ", " & [EmpFirst] AS FirstLast,
Format$(tblEmpPayroll.EmpPayDate,'Long Date') AS [EmpPayDate By Day],
Sum(tblEmpPayroll.EmpHours) AS [Sum Of EmpHours],
Sum(tblEmpPayroll.EmpOTHours) AS [Sum Of EmpOTHours]
FROM tblEmployees INNER JOIN tblEmpPayroll ON tblEmployees.EmpFileNumber =
tblEmpPayroll.EmpNumber
GROUP BY tblEmployees.EmpLast & ", " & [EmpFirst],
Format$(tblEmpPayroll.EmpPayDate,'Long Date'), tblEmployees.EmpFirst,
tblEmpPayroll.EmpNumber
HAVING (((Format$([tblEmpPayroll].[EmpPayDate],'Long Date')) Between
Format(Date()-Weekday(Date()),"\#mm/dd/yyyy\#") And
Format(Date()-Weekday(Date())-7,"\#mm/dd/yyyy\#")));


Thanks,
Ernst.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:37 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.