본문 바로가기
  • 👩🏻‍💻 🌮 💬
💻 leetcode/database

[LeetCode] Database | 181. Employees Earning More Than Their Manager

by 바쿄리 2022. 1. 2.

Problem


 

Example


 

Thinking


input 테이블을 확인하면 Joe의 매니저는 managerId가 3이므로 id가 3인 Sam이 Joe의 매니저이고,

Henry는 똑같은 과정을 거쳐 Max가 매니저임을 알 수 있다.

managerId가 null인 Sam과 Max는 매니저이다.

 

동일 테이블 간의 조인을 위해서 self join을 사용하자!

 

Solve


제출 답안

 

select e1.name as Employee 
    from Employee as e1 INNER JOIN Employee as e2 
    on e1.managerId = e2.id
    where e1.salary > e2.salary


https://leetcode.com/problems/employees-earning-more-than-their-managers/submissions/

 

Employees Earning More Than Their Managers - LeetCode

Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

leetcode.com