题解 | #汇总各个部门当前员工的title类型的分配数目#
汇总各个部门当前员工的title类型的分配数目
http://www.nowcoder.com/practice/4bcb6a7d3e39423291d2f7bdbbff87f8
SELECT B.dept_no,B.dept_name,C.title,COUNT(*) AS 'COUNT' FROM dept_emp A LEFT JOIN departments B ON A.dept_no = B.dept_no AND A.to_date = '9999-01-01' JOIN titles C ON A.emp_no = C.emp_no AND A.to_date = '9999-01-01' GROUP BY dept_no,title ORDER BY dept_no