Sql - Sum of field2 - field1

Diesel

Well-known member
Joined
Aug 18, 2003
Messages
662
Employee
------------

id int,
firstname varchar(30),
lastname varchar(30),


Time Table
-----------
employeeid int,
timein datetime,
timeOut datetime

Need to Sum total hours given employeeid and date range.
 
You can do something like this...

SELECT E.EmployeeID,
Sum(DateDiff("hh",T.TimeIn,T.TimeOut)) AS Hours
FROM Employee E
INNER JOIN TimeTable T
ON E.EmployeeID = T.EmployeeID
WHERE T.SomeDateColumn Between 1/1/1990 And 1/1/2005
GROUP BY E.EmployeeID
 
Back
Top