Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sum in a group

Status
Not open for further replies.

peterpater

Technical User
Jun 15, 2006
13
CA
Hi:
I have a table with the following fields:
-EmpID
-Date
-Event (Project)
-TimeSpentInEvent (in sec)


I am trying to write a query which will give me a sum of TimeSpentInEvent for an event for a day per Employee. (For eg: John may be in a Project from 11am-12pm and 3pm-4pm on Aug 3rd). So the query result would give:
EmpID - John
Date - Aug 3, 2006
TotalTimeSpent - 2hrs (in seconds ofcrs)

I have tried using SUM, but I get the error "Data Type Mismatch in Criteria Expression". I am not too sure if DSum will have, as I am having errors with the syntax.

Any help is appreciated.
 
SELECT EmpID, [Date], Sum(TimeSpentInEvent) AS TotalTimeSpent
FROM yourTable
WHERE [Date] = #2006-08-03# AND Event = 'Project'
GROUP BY EmpID, [Date]

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top