题解 | #获取每个部门中当前员工薪水最高的相关信息#
获取每个部门中当前员工薪水最高的相关信息
http://www.nowcoder.com/practice/4a052e3e1df5435880d4353eb18a91c6
select t3dn,t11en,salary from
((select * from
(select emp_no as t11en, salary from salaries) as t11
left join
(select emp_no as t22en, dept_no as t3dn from dept_emp) as t22
on t11en = t22en) as t3
left join
(select dept_no as t4dn,max(salary) as maxsalary from
((select emp_no as t1en, salary from salaries) as t1
left join
(select emp_no as t2en, dept_no from dept_emp) as t2
on t1en = t2en)
group by dept_no) as t4
on t3dn = t4dn)
where salary = maxsalary
order by t3dn
直接暴力解得,里面可以用t3替代t4里面的一大段 但是我懒得改了
查看6道真题和解析