with out_time as( select attendent_tb.staff_id , case when timestampdiff(minute,first_clockin,last_clockin)>570 then 1 else 0 end as out_time , department from attendent_tb left join staff_tb on attendent_tb.staff_id = staff_tb.staff_id ) select department ,concat(round(sum(out_time)/count(*)*100,1),'%') ratio from out_time group by 1 order by 2 desc

京公网安备 11010502036488号