How can i do the sumation of time in mysql query?

I have a table like this :

enter image description here

And in this table you can see the last column totalloginFinal, I want to do the sum of all time, its will be about 84 hours,

I am trying with addtime and sum function but not getting proper result.

Thanks a lot in Advance.

This question and answers originated from www.stackoverflow.com
Question by (8/29/2011 6:50:14 AM)

Answer

Try this variant -

SELECT SEC_TO_TIME(SUM(TIME_TO_SEC(totalloginFinal))) FROM table_name;

From the reference - The SUM() and AVG() aggregate functions do not work with temporal values. (They convert the values to numbers, which loses the part after the first non-numeric character.) To work around this problem, you can convert to numeric units, perform the aggregate operation, and convert back to a temporal value.

GROUP BY (Aggregate) Functions.

Answer by

Find More Answers
Related Topics  mysql  query
Related Questions