inblog logo
|
stupefyee
    SQL문제풀기

    [SQL 문제 풀이] Employee Bonus (직원 보너스)

    Stupefyee's avatar
    Stupefyee
    May 15, 2025
    [SQL 문제 풀이] Employee Bonus (직원 보너스)
    Contents
    내가 작성한 쿼리
    Employee Bonus - LeetCode
    Can you solve this real interview question? Employee Bonus - Table: Employee +-------------+---------+ | Column Name | Type | +-------------+---------+ | empId | int | | name | varchar | | supervisor | int | | salary | int | +-------------+---------+ empId is the column with unique values for this table. Each row of this table indicates the name and the ID of an employee in addition to their salary and the id of their manager.   Table: Bonus +-------------+------+ | Column Name | Type | +-------------+------+ | empId | int | | bonus | int | +-------------+------+ empId is the column of unique values for this table. empId is a foreign key (reference column) to empId from the Employee table. Each row of this table contains the id of an employee and their respective bonus.   Write a solution to report the name and bonus amount of each employee with a bonus less than 1000. Return the result table in any order. The result format is in the following example.   Example 1: Input: Employee table: +-------+--------+------------+--------+ | empId | name | supervisor | salary | +-------+--------+------------+--------+ | 3 | Brad | null | 4000 | | 1 | John | 3 | 1000 | | 2 | Dan | 3 | 2000 | | 4 | Thomas | 3 | 4000 | +-------+--------+------------+--------+ Bonus table: +-------+-------+ | empId | bonus | +-------+-------+ | 2 | 500 | | 4 | 2000 | +-------+-------+ Output: +------+-------+ | name | bonus | +------+-------+ | Brad | null | | John | null | | Dan | 500 | +------+-------+
    Employee Bonus - LeetCode
    https://leetcode.com/problems/employee-bonus/description/
    Employee Bonus - LeetCode
    notion image
    보너스가 1000달러 미만인 각 직원의 이름과 보너스 금액을 보고하는 솔루션을 작성하세요. 결과 테이블을 순서에 상관없이 반환하세요.
     

    내가 작성한 쿼리

    MySQL, Oracle

    SELECT E.name, B.bonus FROM Employee E LEFT JOIN Bonus B ON B.empId = E.empId WHERE B.bonus < 1000 OR B.bonus IS NULL;
    Share article
    Contents
    내가 작성한 쿼리

    stupefyee

    RSS·Powered by Inblog