select
st.department,
concat(round(count(first_clockin) / count(*) * 100,1) , '%') as ratio



from staff_tb st left join attendent_tb  at
 on st.staff_id = at.staff_id  and   
 TIMESTAMPDIFF(minute, at.first_clockin, at.last_clockin) / 60 > 9.5

 group by st.department order by ratio desc