题目:
Table: Employee
+-------------+---------+
| Column Name | Type |
+-------------+---------+
| id | int |
| name | varchar |
| salary | int |
| managerId | int |
+-------------+---------+
id is the primary key column for this table.
Each row of this table indicates the ID of an employee, their name, salary, and the ID of their manager.
Write an SQL query to find the employees who earn more than their managers.
Return the result table in any order.
给定一个table,找到薪水比他们经理高的人
SELECT a.Name AS EmployeeFROM Employee AS a JOIN Employee AS bON a.ManagerId = b.IdAND a.Salary > b.Salary;
将该表(a表)跟另一个自己(b表)结合
条件设a表ManagerId等于b表的Id且a表的Salary大于b表的Salary
然后把a表的name选出就好
最后执行时间319ms(faster than 92.73%)
那我们下题见