select post, round(avg(timestampdiff(minute,first_clockin,last_clockin))/60,3) as work_hours from staff_tb join attendent_tb using(staff_id) where first_clockin is not null and last_clockin is not null group by post order by work_hours desc
关于本道题题解,关键是找出上下班打卡时间的差异,第一次用timestampdiff(hour,first,last)的时候发现不对,后来仔细观察数据,发现应该用timestamodiff(minute)/以后更准确