题解 | #汇总各个部门当前员工的title类型的分配数目#
汇总各个部门当前员工的title类型的分配数目
https://www.nowcoder.com/practice/4bcb6a7d3e39423291d2f7bdbbff87f8
SELECT D.dept_no, D.dept_name, T.title, COUNT(T.title) AS count FROM dept_emp AS DE LEFT JOIN titles AS T ON T.emp_no = DE.emp_no LEFT JOIN departments AS D ON D.dept_no = DE.dept_no GROUP BY D.dept_no, T.title ORDER BY D.dept_no ASC, T.title ASC;