我正在处理一个 MySQL 查询以返回一些特定的结果。我非常接近。现在,我需要计算两列之间的 TIMEDIFF。这是我当前的查询:
SELECT DATE_FORMAT(PunchDateTime, '%W') DAY, MAX(CASE WHEN PunchEvent = 'ClockIn' THEN DATE_FORMAT(PunchDateTime, '%r') END) AS 'Clock In', MAX(CASE WHEN PunchEvent = 'BreakOut' THEN
DATE_FORMAT(PunchDateTime, '%r') END) AS 'Break Out', MAX(CASE WHEN PunchEvent = 'BreakIn' THEN DATE_FORMAT(PunchDateTime, '%r') END) 'Break In', MAX(CASE WHEN PunchEvent = 'ClockOut' THEN
DATE_FORMAT(PunchDateTime, '%r') END) 'Clock Out', TIMEDIFF('Clock In', 'Break Out') AS Total FROM timeclock_punchlog WHERE EmpID = 456 GROUP BY
DATE_FORMAT(PunchDateTime, '%W') ORDER BY PunchDateTime;
现在,Total 显示 00:00:00。任何想法我怎么能做到这一点?谢谢迈克