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

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

skys215 has written 118 articles

没有bug的代码是有bug的代码。

积分:5832 等级:P8 职业:PHP工程师 城市:深圳

0 条回复

登录后才能进行评论,立即登录?