题解 | 统计各岗位员工平均工作时长
select t1.post as post ,avg(ROUND((UNIX_TIMESTAMP(t2.last_clockin) - UNIX_TIMESTAMP(t2.first_clockin)) / 3600,3)) AS work_hours from staff_tb t1 inner join attendent_tb t2 on t1.staff_id = t2.staff_id group by t1.post order by work_hours desc;
我看大家都是使用timestampdiff,可以使用UNIX_TIMESTAMP直接得到结果。
