select c.department,concat(round(if(c2/c1*100,c2/c1*100,0),1),'%') as ratio from (select department,count(*) as c2 from attendent_tb a,staff_tb s where timestampdiff(minute ,first_clockin,last_clockin)/60>9.5 and a.staff_id=s.staff_id group by department) b right join (select department, count(staff_id) as c1 from staff_tb st group by department) c on b.department=c.department order by ratio desc ;



京公网安备 11010502036488号