题解 | 统计加班员工占比
统计加班员工占比
https://www.nowcoder.com/practice/6c0a521c36e14c7599eaef858f6f8233
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