SQL Fiddle
Setting up the MS SQL Server 2008 schema :
CREATE TABLE Table2 ([repID] int, [ClockIn] datetime, [ClockOut] datetime, [TotalHours] varchar(7)) ; INSERT INTO Table2 ([repID], [ClockIn], [ClockOut], [TotalHours]) VALUES (109145, '7:50:50 AM', '3:37:16 PM', '7:46:26'), (109145, '7:52:41 AM', '3:44:51 PM', '7:52:10'), (109145, '8:42:40 AM', '3:46:29 PM', '7:3:49'), (109145, '7:50:52 AM', '3:42:59 PM', '7:52:7'), (109145, '8:09:23 AM', '3:36:55 PM', '7:27:32') ;
Request 1 :
SELECT convert(varchar(8), dateadd(second, SUM(DATEDIFF(SECOND, ClockIn, ClockOut)), 0), 108) from Table2 group by repID
Results :
| COLUMN_0 | ------------ | 14:02:04 |
Request 2 :
select sum(datediff(second,ClockIn,ClockOut))/3600 as hours_worked from Table2
Results :
| hours_worked| ------------ | 38 |
Request 3 :
select sum(datediff(minute, 0, TotalHours)) / 60.0 as hours_worked from Table2
Results :
| HOURS_WORKED | ---------------- | 38 |
Here, the last request was taken from FreeLancers answer, as I really wanted to know if it works or not.
Here, you first need to convert the time and time difference into a second or a minute, and then convert that time back to an hour.
Hope this helps.