select
b.staff_id,
a.staff_name,
concat (
round(
sum(b.dock_salary) / sum(b.normal_salary) * 100,
1
),
'%'
) as dock_ratio
from
salary_tb b
left join staff_tb a on a.staff_id = b.staff_id
where
a.department = 'dep1'
group by
b.staff_id,
a.staff_name
order by dock_ratio desc

京公网安备 11010502036488号