Calculating the total length of time in MySQL

I have 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 this. like 17:33:00. Can anyone query a mysql query to calculate this.

+6
sql mysql
source share
1 answer

Try converting to seconds, summarize, and then go back to time:

 SELECT SEC_TO_TIME(SUM(TIME_TO_SEC(Duration))) FROM Table1 

Result:

 17:33:00 
+16
source share

All Articles