题解 | #统计各个部门的工资记录数#
统计各个部门的工资记录数
https://www.nowcoder.com/practice/6a62b6c0a7324350a6d9959fa7c21db3
select a.dept_no,a.dept_name,count(salary) sum from salaries s left join (SELECT dp.emp_no,dp.dept_no,dp.from_date,dp.to_date,de.dept_name FROM departments de RIGHT JOIN dept_emp dp on de.dept_no = dp.dept_no) a on s.emp_no = a.emp_no GROUP BY a.dept_no order by a.dept_no