用where将三个表根据dept_no,emp_no连接起来,然后根据dept_no分组并用count()计算每组多少个工资记录,然后根据dept_no进行排序。最后选出dept_no,dept_name和工资记录数count()。

select d.dept_no, d.dept_name, count(s.salary) from 
departments as d, dept_emp as de, salaries as s
where d.dept_no = de.dept_no and de.emp_no = s.emp_no
group by d.dept_no
order by d.dept_no