select post, round(avg(timestampdiff(second,first_clockin,last_clockin)/3600),3) work_hours
from staff_tb s 
inner join attendent_tb a 
on s.staff_id=a.staff_id 
group by post
order by work_hours desc;
主要在于时间戳差值这个函数,用hour时得到的是整数,那还是用具体的分或秒来转换回小时得到有小数的值;null其实会被avg函数过滤掉,我就没写