postgresql - Calculating total working hours based on shifts -
i calculate how many hours each employee has worked time period, based on information table:
start employee_id 2014-08-10 18:10:00 5 2014-08-10 13:30:00 7 2014-08-10 09:00:00 7 2014-08-09 23:55:00 4 2014-08-09 16:23:00 12 2014-08-09 03:59:00 9 2014-08-08 20:05:00 7 2014-08-08 13:00:00 8 each employee replaces employee , that's work done, there no empty slots.
the desired format of result following:
employee_id total_minutes_worked i'm trying think of best way achieve this, appreciated!
you can total time as:
select employee_id, sum(stop - start) ( select start, lead(start) on (order start) stop, employee_id t ) x group employee_id; it remains format time, assume not puzzles you
Comments
Post a Comment