题解 | 统计各个部门平均薪资
select t1.department as department ,round(avg(t2.normal_salary - t2.dock_salary),3) as avg_salary from staff_tb as t1 join salary_tb as t2 on t1.staff_id = t2.staff_id where (t2.normal_salary - t2.dock_salary) >= 4000 and (t2.normal_salary - t2.dock_salary) <= 30000 group by t1.department order by avg_salary desc;