select dept_no, count(salary) as sum
from salaries left outer join dept_emp
on salaries.emp_no = dept_emp.emp_no
group by dept_no;
select ds.dept_no, dept_name, sum
from departments,
(select dept_no, count(salary) as sum
from salaries left outer join dept_emp
on salaries.emp_no = dept_emp.emp_no
group by dept_no) as ds
where departments.dept_no = ds.dept_no
order by ds.dept_no;
只要是逻辑思考完毕,这些题真的就是费时间,但不困难了。
但是时间,或者说效率,是我亟需提高的。