题解 | 统计员工薪资扣除比例
with tmp as ( select t1.staff_id ,t1.staff_name ,t2.normal_salary ,t2.dock_salary from (select * from staff_tb where department = 'dep1') t1 left join salary_tb as t2 on t1.staff_id = t2.staff_id) select t.staff_id as staff_id ,t.staff_name as staff_name ,concat(round(((t.dock_salary / t.normal_salary) * 100),1),'%') as dock_ratio from tmp as t order by dock_ratio desc;