题解 | #统计各个部门的工资记录数#
统计各个部门的工资记录数
http://www.nowcoder.com/practice/6a62b6c0a7324350a6d9959fa7c21db3
SELECT dept_no,dept_name,(select count(sa.emp_no) from salaries sa where
EXISTS(SELECT 1 from dept_emp
where sa.emp_no in (SELECT emp_no
from dept_emp de
where de.dept_no =des.dept_no )))
from departments des
EXISTS(SELECT 1 from dept_emp
where sa.emp_no in (SELECT emp_no
from dept_emp de
where de.dept_no =des.dept_no )))
from departments des
感觉自己再看一遍都看不懂。。。