您的位置:首页 > 数据库 > MySQL

【MySQL】【leetcode】 Employees Earning More Than Their Managers解题报告

2015-10-20 17:09 471 查看

题目

The Employee table holds all employees including their managers. Every employee has an Id, and there is also a column for the manager Id.

IdNameSalaryManagerId
1Joe700003
2Henry800004
3Sam60000NULL
4Max90000NULL
Given the Employee table, write a SQL query that finds out employees who earn more than their managers. For the above table, Joe is the only employee who earns more than his manager.

+———-+

| Employee |

+———-+

| Joe |

+———-+

代码

到底谁比它主管的工资还高?

# Write your MySQL query statement below
select e1.Name as Employee
from Employee as e1, Employee as e2
where e1.ManagerId = e2.Id and e1.Salary > e2.Salary;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  数据库 mysql leetcode