我正在使用以下查询,除了“时间”列之外,该查询运行良好。我的输出为 hhmmss
,但我想要 hh:mm:ss
select Agent_ID, date(Start_Time),
SUM(CASE WHEN Break_Reason = 'teabreak' THEN login.Time ELSE NULL END) TeaBreak
from login
where Agent_ID = '3331'
and date(start_time) = '2016-04-02';
如何解决?
最佳答案
看一下 date_format(日期, 格式):
select Agent_ID, date_format(date(Start_Time),'%H:%i:%S'),
SUM(CASE WHEN Break_Reason = 'teabreak' THEN login.Time ELSE NULL END) TeaBreak
from login
where Agent_ID = '3331'
and date(start_time) = '2016-04-02';
有关更多信息,请查看:http://www.w3schools.com/sql/func_date_format.asp
关于mysql - 为什么Mysql时间输出值显示为hhmmss而不是hh :mm:ss?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37021508/