在MySQL查询中总结小时和分钟

时间:2013-06-22 04:32:47

标签: mysql date datetime

运行查询后,我得到一个类似于MySQL下面的列

TimeDiff
03:45:07
03:28:59
00:36:16
00:59:42
02:44:18

现在我想在同一个查询中一起总结时间。示例查询如下所示

SELECT timediff(OutTime, InTime) AS TimeDiff
  FROM Table1 

我尝试了Sum和SEC_TO_TIME,但我使用的方式不对。

请让我知道如何总结时间到达11:53:33

1 个答案:

答案 0 :(得分:1)

SELECT
  SEC_TO_TIME(SUM(tbl.TimeDiff)) as TimeDifferent
FROM
  (SELECT TIME_TO_SEC(timediff(OutTime, InTime)) AS TimeDiff
   FROM Table1) as tbl