SELECT post, ROUND(AVG(work_hours), 3) AS work_hours
FROM (SELECT staff_id, TIME_TO_SEC(TIMEDIFF(last_clockin, first_clockin)) / 3600 AS work_hours FROM attendent_tb) t
LEFT JOIN staff_tb s ON s.staff_id = t.staff_id
GROUP BY post
ORDER BY work_hours DESC;

京公网安备 11010502036488号