【发布时间】:2018-09-30 18:32:00
【问题描述】:
我有一个需要总结的时间列表。我有两张表:workers 和 schedule。
CREATE TABLE schedule (
id,
worker_id,
date,
start_time,
end_time,
hours
SELECT w.name, w.salary, time(sum(strftime('%s', hours) - strftime('%s', '00:00:00')), 'unixepoch') AS total_hours
FROM workers w
JOIN schedule s ON s.worker_id = w.id
WHERE date between '2018-09-17' AND '2018-09-21'
GROUP BY w.name
小时数列包含每天工作的总小时数。我找到了一些其他帖子,但不是我需要的解决方案。
- sqlite: how to add total time hh:mm:ss where column datatype is DATETIME?
- sqlite: sum time over 24h to HHH:MM:SS
问题
图片时间表
如果我将 24Hrs 下的值相加,则此请求可以正常工作:例如 10:00 + 07:00,总数将为:17:00,但如果我将更多时间相加:10:00 + 07:00 + 09:00 我将得到: 02:00.
我不知道我做错了什么。
我正在寻找的结果:
Worker | Salary | Total Hours
John Doe | $28.00 | 26:00
worker 1 | $30.00 | 20:15
worker 2 | $25.00 | 42:30
【问题讨论】: