select
department,
concat(
cast(
round(
count(
if(
timestampdiff(minute, first_clockin, last_clockin) > 570,
1,
null
)
) / count(*) * 100,
1
) as CHAR
),
"%"
) as ratio
from
staff_tb st
inner join attendent_tb at on st.staff_id = at.staff_id
group by
department
order by
ratio desc

京公网安备 11010502036488号