使用SQL计算类型时间的总和 [英] calculate a sum of type time using sql
本文介绍了使用SQL计算类型时间的总和的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何计算具有以下格式的称为"timeSpent"的我的殖民地的时间总和:HH:mm 在SQL中?我正在使用MySQL.
How to caculate sum of times of my colonne called "timeSpent" having this format: HH:mm in SQL? I am using MySQL.
我的列的类型是时间.
它具有这种结构
TimeFrom like 10:00:00 12:00:00 02:00:00
TimeUntil 08:00:00 09:15:00 01:15:00
Time spent
total time 03:15:00
推荐答案
SELECT SEC_TO_TIME( SUM( TIME_TO_SEC( `timeSpent` ) ) ) AS timeSum
FROM YourTableName
这对我有用.希望这会有所帮助.
This worked for me. Hope this helps.
这篇关于使用SQL计算类型时间的总和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文