题解 | #统计各个部门的工资记录数#
统计各个部门的工资记录数
http://www.nowcoder.com/practice/6a62b6c0a7324350a6d9959fa7c21db3
select dept_no,dept_name,sum from
departments NATURAL JOIN
(select dept_no,count(emp_no) as sum from
(select dept_emp.emp_no,dept_emp.dept_no from dept_emp inner join salaries
on dept_emp.emp_no = salaries.emp_no) as jt
group by dept_no) as t2;