select department,
concat(round(sum(if(round(timestampdiff(minute, first_clockin, last_clockin)/60,1)>9.5,1,0))/count(*)*100,1),'%') ratio
from staff_tb s join attendent_tb a on s.staff_id = a.staff_id 
group by department
order by ratio desc