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


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%的代码…很好奇该如何优化。

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


Vote Vote Cancel Collect Collect Cancel

<< 上一篇: Leetcode基础刷题之PHP解析(59. Spiral Matrix II)

>> 下一篇: Leetcode基础刷题之PHP解析(216. Combination Sum III)