题解 | #汇总各个部门当前员工的title类型的分配数目#
汇总各个部门当前员工的title类型的分配数目
http://www.nowcoder.com/practice/4bcb6a7d3e39423291d2f7bdbbff87f8
思路:合并所有表,group by department 和 title(之前没有group by title就会被单独count)
select de.dept_no as dept_no, dn.dept_name as dept_name, t.title as title, count(t.emp_no) as count from dept_emp de, departments dn, titles t
where de.dept_no = dn.dept_no
and de.emp_no = t.emp_no
group by de.dept_no, t.title
order by dept_no, title asc