子查询
汇总各个部门当前员工的title类型的分配数目
http://www.nowcoder.com/questionTerminal/4bcb6a7d3e39423291d2f7bdbbff87f8
select d.dept_no,d.dept_name,a.title,
a.count_title as count
from departments d
join
(
select dept_no,title,count(t.title) as count_title
from dept_emp de
join titles t
on de.emp_no=t.emp_no
and de.to_date = '9999-01-01' and t.to_date = '9999-01-01'
group by de.dept_no,t.title
) a
on d.dept_no=a.dept_no