SELECT
s.post,
ROUND(AVG(TIMESTAMPDIFF(minute,a.first_clockin,a.last_clockin)/60),3) AS work_hours
FROM
staff_tb s
JOIN attendent_tb a ON s.staff_id=a.staff_id
WHERE
a.first_clockin IS NOT NULL
AND a.last_clockin IS NOT NULL
GROUP BY
s.post
ORDER BY
work_hours DESC
IS NOT NULL代表非空

京公网安备 11010502036488号