题解 | #获取每个部门中当前员工薪水最高的相关信息#
获取每个部门中当前员工薪水最高的相关信息
http://www.nowcoder.com/practice/4a052e3e1df5435880d4353eb18a91c6
select y.dept_no,y.emp_no,maxSalary from
(select dept_no,d.emp_no,salary from dept_emp as d,salaries as s
where d.emp_no = s.emp_no
)as y
join
(select d.dept_no,max(salary) as maxSalary from dept_emp as d,salaries as s
where s.emp_no = d.emp_no
group by dept_no) as t
on y.salary = t.maxSalary
and y.dept_no = t.dept_no
order by t.dept_no;