题解 | #汇总各个部门当前员工的title类型的分配数目#
汇总各个部门当前员工的title类型的分配数目
http://www.nowcoder.com/practice/4bcb6a7d3e39423291d2f7bdbbff87f8
连接三个表,分组之后,再count计算 然后order by 排序完事
select dp.dept_no,dp.dept_name,t.title,count(t.emp_no)
from dept_emp as de
left join departments as dp
on de.dept_no= dp.dept_no
left join titles as t
on de.emp_no=t.emp_no
group by dp.dept_no,dp.dept_name,t.title
order by dp.dept_no,t.title;