题解 | #汇总各个部门当前员工的title类型的分配数目#
汇总各个部门当前员工的title类型的分配数目
https://www.nowcoder.com/practice/4bcb6a7d3e39423291d2f7bdbbff87f8
SELECT dept_no,dept_name,title,count(1) 'count' FROM dept_emp JOIN titles USING(emp_no) JOIN departments USING(dept_no) WHERE dept_emp.to_date = '9999-01-01' GROUP BY dept_no,title ORDER BY dept_no,title
这个是比较常规的group by分组两个字段(dept_no,title)即可