题解 | #汇总各个部门当前员工的title类型的分配数目#
汇总各个部门当前员工的title类型的分配数目
https://www.nowcoder.com/practice/4bcb6a7d3e39423291d2f7bdbbff87f8
select dept_no, dept_name, title, count(title) as count1 from (select ds.dept_no, ds.dept_name, t0.title from (select d.dept_no,t.title from titles t left join dept_emp d on t.emp_no = d.emp_no where t.to_date='9999-01-01')t0 left join departments ds on ds.dept_no = t0.dept_no )t1 group by dept_no,dept_name,title order by dept_no asc,title asc