在StackOverflow上尝试所有解决方案后,我仍然无法将时间转换为mm:ss。
我试过time_format,date_format,Substring,left,right。
我的查询是:
SELECT location,sec_to_time(AVG(time_to_sec(time_avg))) as timeAVG
FROM test.test
group by location
输出是:
'zone1', '00:26:13.3333'
或类似的其他项目是我尝试的所有上述方法转换时间,但留下0代替我已删除的项目,例如。
SELECT location,sec_to_time(AVG(time_to_sec(time_format(time_avg, '%i:%s')))) as timeAVG
FROM test.test
group by location
将返回:
'zone1', '26:13:20.0000'
与date_format相同
substring
,left
和right
都返回与提供的第一个值相同的
如果我跑:
select location,TIME_FORMAT(time_avg,'%i:%s')
from test.test
group by location
它正确地将时间格式化为:
'zone1', '29:47'
但查询并没有返回我之后的值。
答案 0 :(得分:1)
这是你想要的吗?
select location,TIME_FORMAT(time_avg,'%i:%s.%f') from test.test group by location;