inblog logo
|
stupefyee
    SQL문제풀기

    [SQL 문제 풀이] Employees Earning More Than Their Managers (관리자보다 더 많은 수익을 올리는 직원)

    Stupefyee's avatar
    Stupefyee
    May 22, 2025
    [SQL 문제 풀이] Employees Earning More Than Their Managers (관리자보다 더 많은 수익을 올리는 직원)
    Contents
    내가 작성한 쿼리
    Employees Earning More Than Their Managers - LeetCode
    Can you solve this real interview question? Employees Earning More Than Their Managers - Table: Employee +-------------+---------+ | Column Name | Type | +-------------+---------+ | id | int | | name | varchar | | salary | int | | managerId | int | +-------------+---------+ id is the primary key (column with unique values) for this table. Each row of this table indicates the ID of an employee, their name, salary, and the ID of their manager.   Write a solution to find the employees who earn more than their managers. Return the result table in any order. The result format is in the following example.   Example 1: Input: Employee table: +----+-------+--------+-----------+ | id | name | salary | managerId | +----+-------+--------+-----------+ | 1 | Joe | 70000 | 3 | | 2 | Henry | 80000 | 4 | | 3 | Sam | 60000 | Null | | 4 | Max | 90000 | Null | +----+-------+--------+-----------+ Output: +----------+ | Employee | +----------+ | Joe | +----------+ Explanation: Joe is the only employee who earns more than his manager.
    Employees Earning More Than Their Managers - LeetCode
    https://leetcode.com/problems/employees-earning-more-than-their-managers/description/
    Employees Earning More Than Their Managers - LeetCode
    notion image
    관리자보다 더 많은 수입을 올리는 직원들을 찾기 위한 해결책을 작성하세요. 결과 테이블을 순서에 상관없이 반환하세요.
     

    내가 작성한 쿼리

    MySQL, Oracle

    SELECT E1.name Employee FROM Employee E1 JOIN Employee E2 ON E1.managerId = E2.id WHERE E1.salary > E2.salary;
    Share article
    Contents
    내가 작성한 쿼리

    stupefyee

    RSS·Powered by Inblog