MySQL TIMEDIFF()返回两次之间的差异和时间总和

时间:2015-01-13 10:45:54

标签: mysql

我的查询是我想找到timediff函数的总和任何帮助

SELECT TIMEDIFF( timefrom, timeto )
FROM `leaveapply`
WHERE userid = '21'
GROUP BY leavetype
LIMIT 0 , 30

以下语句将返回这样的时间

00:00:00
00:00:00
01:00:00
02:00:00

我想总结并得到结果, 像这样03:00:00

1 个答案:

答案 0 :(得分:0)

尝试这样的事情:

select sum(
            SELECT TIMEDIFF( timefrom, timeto ) FROM `leaveapply`
            WHERE userid = '21'
            GROUP BY leavetype
          ) as total