LeetCode > 181. Employees Earning More Than Their Managers

Jihyun Park·2020년 9월 13일
0
post-thumbnail

181. Employees Earning More Than Their Managers

Problem

The Employee table holds all employees including their managers. Every employee has an Id, and there is also a column for the manager Id. 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.
문제링크

Answer

SELECT e1.name AS Employee
FROM Employee AS e1
    INNER JOIN Employee AS e2 ON e1.managerID = e2.ID
WHERE e1.salary > e2.Salary
-- SELF JOIN은 자기 자신의 테이블과 조인하는 것.

1개의 댓글

comment-user-thumbnail
2021년 12월 22일

I found that solution very popular and helpful: https://www.youtube.com/watch?v=UbNU98fKV8o&ab_channel=EricProgramming

답글 달기