Leetcode PHP题解--D112 181. Employees Earning More Than...

skys215

D112 181. Employees Earning More Than Their Managers

题目链接

181. Employees Earning More Than Their Managers

题目分析

给定一张表,返回工资比上级高的员工名字。

思路

我想到的是left join。

最终代码

# Write your MySQL query statement below
#SELECT Employee.Name as Employee FROM Employee, Employee as Manager where Employee.ManagerId=Manager.Id and Employee.Salary>Manager.Salary;
SELECT Employee.Name as Employee FROM Employee LEFT JOIN Employee as Manager ON Employee.ManagerId=Manager.Id WHERE Employee.Salary>Manager.Salary;

但这语句只打败了12%的代码…很好奇该如何优化。

若觉得本文章对你有用,欢迎用爱发电资助。

阅读 927
42 声望
26 粉丝
0 条评论
42 声望
26 粉丝
文章目录
宣传栏