三表连接,因为只是查记录条数,所有不用筛选在职人员
select d.dept_no,ds.dept_name,count(s.salary) sum
from dept_emp d join salaries s on d.emp_no=s.emp_no 
 join departments ds on d.dept_no=ds.dept_no
group by d.dept_no
order by d.dept_no