sql 184.部门最高薪水(第1名).sql

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql 184.部门最高薪水(第1名).sql相关的知识,希望对你有一定的参考价值。

# Write your MySQL query statement below
SELECT D.Name AS Department, E.Name AS Employee, E.Salary AS Salary
FROM Employee AS E 
JOIN  Department AS D ON E.DepartmentId = D.Id
JOIN  (SELECT E2.DepartmentId AS DepartmentId, MAX(E2.Salary) AS maxSalary
                    FROM Employee AS E2
                    GROUP BY E2.DepartmentId) AS T ON E.Salary = T.maxSalary and T.DepartmentId = E.DepartmentId

# Write your MySQL query statement below
select D.Name as Department, M.Name as Employee, M.Salary as Salary
from Department D, (select E1.Name, E1.Salary, E1.DepartmentId from Employee E1 join
                    (select Name, MAX(Salary) as Salary, DepartmentId from Employee group by DepartmentId)as E2
                     on E1.DepartmentId = E2.DepartmentId
                     where E1.Salary = E2.Salary)as M
where D.Id = M.DepartmentId;

以上是关于sql 184.部门最高薪水(第1名).sql的主要内容,如果未能解决你的问题,请参考以下文章

sql 184.部门最高薪水(第1名).sql

sql 184.部门最高薪水(第1名).sql

sql 184.部门最高薪水(第1名).sql

sql 184.部门最高薪水(第1名).sql

5取得平均薪水最高的部门的部门编号bjpowernode34道SQL题

6取得平均薪水最高的部门的部门名称bjpowernode34道SQL题