select s.department, concat(round(count(case when timestampdiff(minute,a.first_clockin,a.last_clockin)/60>9.5 then 1 else null end)/count(s.staff_id)*100,1),'%') as ratio from staff_tb s join attendent_tb a on s.staff_id = a.staff_id group by s.department order by ratio desc
一把过