๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
SQL/LeetCode

[LeetCode][SQL50] #11. Employee Bonus

by ์ด๋ฎด 2023. 11. 8.
728x90

๐Ÿ’ป ๋ฌธ์ œ ์ฃผ์†Œ : Employee Bonus - LeetCode

 

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

leetcode.com

 

๐Ÿ’ป ๋ฌธ์ œ

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.

- ๋ณด๋„ˆ์Šค๋ฅผ 100๋ณด๋‹ค ์ ๊ฒŒ ๋ฐ›๋Š” ๋ชจ๋“  ์ง์›๋“ค์˜ ์ด๋ฆ„๊ณผ ๋ณด๋„ˆ์Šค ๊ธˆ์•ก์„ ๊ตฌํ•˜์‹œ์˜ค. ์ถœ๋ ฅ ์ˆœ์„œ๋Š” ์ƒ๊ด€ ์—†์Šต๋‹ˆ๋‹ค.

 

๐Ÿ’ป ์ฝ”๋“œ ๋ฐ ํ’€์ด 

select Employee.name, Bonus.bonus
from Employee
left join Bonus using (empId)
where Bonus.bonus < 1000 or Bonus.bonus is null

 

728x90
๋ฐ˜์‘ํ˜•