-- 0.出勤信息表与出勤信息表 根据staff_id关联 -- 1.对部门分组,按分钟求出工作时长转换为小时,并求平均值保留三位小数 select post , round(avg(TIMESTAMPDIFF(MINUTE,first_clockin,last_clockin)/60) ,3)as work_hours from attendent_tb a join staff_tb s on a.staff_id=s.staff_id group by post order by work_hours desc