184. 部门工资最高的员工
Posted letlifestop
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了184. 部门工资最高的员工相关的知识,希望对你有一定的参考价值。
184. 部门工资最高的员工
需要注意的几个点,inner join可以缩减成join,取的是两个表的交集
in关键词,找的是当前所要找的数值是否在指定的范围之中
# Write your mysql query statement below select d.Name as Department, e.Name as Employee, e.Salary from Employee e inner join Department d on e.DepartmentId = d.Id where (DepartmentId, e.Salary) in (select DepartmentId, max(Salary) from Employee group by DepartmentId);
这个是有问题的版本,暂时还不知道怎么改,只是提示group by使用错误
# Write your MySQL query statement below
select d.Name as Department, e1.Name as Employee,
max(e1.Salary) as Salary from Employee e1, Employee e2,
Department d where e1.Salary >= max(e2.Salary)
and
e1.DepartmentId = e2.DepartmentId group by e1.Id order by e1.Salary desc;
以上是关于184. 部门工资最高的员工的主要内容,如果未能解决你的问题,请参考以下文章