tags:

views:

35

answers:

1

i have a table data like this

(int)   (time)  [mySQL datatype]

Id     Duration 
------------------
1      00:10:00
2      10:10:00
3      03:00:00
4      04:13:00

i want to calculate the total duration from this table, how can we do it. like 17:33:00. Could anybody please provide mysql query to calculate this.

+5  A: 

Try this:

SELECT CAST(SUM(Duration) AS Time)
FROM Table1
WHERE Duration IS NOT NULL

Result:

17:33:00
Mark Byers
but it is returning null in result
A.P.S
@A.P.S: That's probably becasue some of the durations are NULL. Add `WHERE Duration IS NOT NULL` after `FROM Table1` and it should fix the problem.
Mark Byers