题解 | #获取员工其当前的薪水比其manager当前薪水还高的相关信息#
汇总各个部门当前员工的title类型的分配数目
http://www.nowcoder.com/practice/4bcb6a7d3e39423291d2f7bdbbff87f8
运行时间60ms
Select distinct dept_no,dept_name,title, (select count(title) from titles t1 where emp_no in (select emp_no from dept_emp de1 where de1.dept_no = de2.dept_no and t1.title = t2.title)) as 'count' from titles t2 join dept_emp de2 using(emp_no) join departments using(dept_no) order by dept_no,title
写的越来越不知道是什么了 只是能通过
再看题解发现用group by会好一点