LIX
LIX

Reputation: 1529

sum of Times in SQL

I have some records like this:

ID       Personel_Code        Time 
---      -------------       ------ 
1         0011                05:50
3         0011                20:12
4         0012                00:50

I want to have the sum of times for each person. in this example I want to have the result like this :

Personel_Code          Time
-------------          -----
 0011                  26:02
 0012                   00:50

Thank you.

Upvotes: 1

Views: 1200

Answers (1)

zarko.susnjar
zarko.susnjar

Reputation: 2053

Probably you'd do something like this in SQL Server (just a hint, you have to work on details and conversions)

SELECT Personel_Code, SUM(DATEDIFF(MINUTE, '0:00:00', convert(time, Time, 8))) as totalTime
FROM thisTable
GROUP BY Personel_Code

Upvotes: 1

Related Questions