题解 | #汇总各个部门当前员工的title类型的分配数目#
汇总各个部门当前员工的title类型的分配数目
http://www.nowcoder.com/practice/4bcb6a7d3e39423291d2f7bdbbff87f8
主要是group by联合分组的考察
select d.dept_no, d.dept_name, t.title, count(*) as count from departments as d inner join dept_emp as de on d.dept_no = de.dept_no and de.to_date = '9999-01-01' inner join titles as t on de.emp_no = t.emp_no and t.to_date = '9999-01-01' group by de.dept_no, t.title order by de.dept_no ;