题解 | #统计各个部门的工资记录数#
统计各个部门的工资记录数
http://www.nowcoder.com/practice/6a62b6c0a7324350a6d9959fa7c21db3
# 部门的工资记录数
select d.dept_no,dept_name,sum(a.sum_n)
from dept_emp d
left join departments dp
on d.dept_no = dp.dept_no
left join (select emp_no,count(salary) as sum_n from salaries
group by emp_no)a
on d.emp_no = a.emp_no
group by d.dept_no
order by dept_no