美文网首页Leetcode题解-PHP版
Leetcode PHP题解--D112 181. Employ

Leetcode PHP题解--D112 181. Employ

作者: skys215 | 来源:发表于2019-08-02 11:15 被阅读0次

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

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

    相关文章

      网友评论

        本文标题:Leetcode PHP题解--D112 181. Employ

        本文链接:https://www.haomeiwen.com/subject/srokdctx.html