select a.dept_no,a.dept_name,count(1) as 'sum'
from departments a 
left join dept_emp b 
on a.dept_no = b.dept_no
left join salaries c 
on b.emp_no = c.emp_no
group by a.dept_no
order by dept_no

把所有表连起来就好了

顺便记一下count(1)和count(*)的区别,count(*)会统计表中所有行,包括存在null的行,而count(1)则只会统计有值的行,忽略bull的行