I have a list of times that I need to sum. I have two tables: workers and 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
The column hours contain the total of hours worked for every day. I found some other posts, but not the solution that I need.
- sqlite: how to add total time hh:mm:ss where column datatype is DATETIME?
- sqlite: sum time over 24h to HHH:MM:SS
Problem
Image schedule table
This request works fine if I sum values under 24Hrs : example 10:00 + 07:00 the total will be : 17:00, but if I sum more times : 10:00 + 07:00 + 09:00 I will get :02:00.
I don't know what I am doing wrong.
The result what I am looking for :
Worker | Salary | Total Hours
John Doe | $28.00 | 26:00
worker 1 | $30.00 | 20:15
worker 2 | $25.00 | 42:30