题解 | #统计各岗位员工平均工作时长#
统计各岗位员工平均工作时长
https://www.nowcoder.com/practice/b7220791a95a4cd092801069aefa1cae
SELECT A.post,AVG(TIMESTAMPDIFF(MINUTE,B.first_clockin,B.last_clockin)/60) AS work_hours FROM staff_tb A JOIN attendent_tb B ON A.staff_id=B.staff_id GROUP BY A.post ORDER BY AVG(TIMESTAMPDIFF(MINUTE,B.first_clockin,B.last_clockin)/60) DESC