select department, concat(round(count(if(wt > 9.5, 1, null))/count(*)*100,1), '%') ratio from( select a.staff_id, department, timestampdiff(minute, first_clockin, last_clockin)/60 wt from ( select * from attendent_tb at where first_clockin is not null ...