select department,concat( round( (sum(case when timestampdiff(minute,first_clockin,last_clockin)/60>9.5 then 1 else 0 end)/count(a.staff_id))*100,1),'%' ) as ratio from staff_tb a left join attendent_tb b using(staff_id) group by department order by ratio DESC