题解 | #统计各个部门的工资记录数#
统计各个部门的工资记录数
https://www.nowcoder.com/practice/6a62b6c0a7324350a6d9959fa7c21db3
select dept_no,dept_name,count(dept_no) as sum from salaries left join ( select emp_no,dept_emp.dept_no as dept_no,dept_name from dept_emp left join departments on dept_emp.dept_no=departments.dept_no )as t on salaries.emp_no=t.emp_no group by dept_no order by dept_no;
窗口函数做