三表连接, 然后用group by

select d.dept_no, d.dept_name, count(s.salary) as sum 
from departments d 
join dept_emp e 
on d.dept_no=e.dept_no
join salaries s 
on e.emp_no = s.emp_no
group by d.dept_no
order by d.dept_no asc;