select post, round(avg(diff),3) as work_hours from ( select TIMESTAMPDIFF(MINUTE,first_clockin,last_clockin)/60 as diff,staff_id from attendent_tb where first_clockin is not null and last_clockin is not null )t1 inner join staff_tb t2 on t1.staff_id = t2.staff_id group by post order by 2 desc
TIMESTAMPDIFF(HOUR,first_clockin,last_clockin) 好像只能返回整数?