yokostan / Leetcode-Solutions

Doing exercise on Leetcode. Carry on!
0 stars 3 forks source link

Leetcode #181. Employees Earning More Than Their Managers #212

Open yokostan opened 5 years ago

yokostan commented 5 years ago
# Write your MySQL query statement below
SELECT e.Name as Employee
FROM Employee e
WHERE e.Salary > (
    SELECT Salary
    FROM Employee
    WHERE Id = e.ManagerId
)
yokostan commented 5 years ago

Above solution runtime beats 5%. Here is the most common one:

select a.name as Employee

from employee as A,
employee as B

where a.ManagerID=b.ID
and a.salary > b.salary