题解 | 统计加班员工占比
select
department,
concat (
round(
count(
if (
timestampdiff (minute, first_clockin, last_clockin) > (9.5 * 60),
1,
null
)
) / count(st.staff_id) * 100,
1
),
'%'
) as ratio
from
staff_tb st,
attendent_tb at
where
st.staff_id = at.staff_id
group by
department
order by
ratio desc