题目
表:Employee
编写一个SQL查询来查找收入比经理高的员工。
以 任意顺序 返回结果表。
查询结果格式如下所示。
示例 1:
解题思路
1、通过连接,先找到员工的经理。
2、找到员工对应的经理后,再对比两者工资。
3、选择满足条件的员工名字返回即可。
代码实现
select a.name as Employee
from Employee as a, Employee as b
where a.managerId = b.Id and a.salary > b.salary
运行结果