题解 | 统计各岗位员工平均工作时长
WITH temp AS ( SELECT post, round(timestampdiff(second, first_clockin, last_clockin)/3600,3) as work_time FROM attendent_tb a INNER JOIN staff_tb b ON a.staff_id = b.staff_id ) select post ,avg(work_time) as work_hours from temp group by post order by work_hours desc