본문 바로가기
🛠️Skill/CodingTest

[leetcode] 577. Employee Bonus / COALESCE

by Istj_eff 2023. 1. 15.

577. Employee Bonus

 

https://leetcode.com/problems/employee-bonus/

 

Employee Bonus - LeetCode

Can you solve this real interview question? Employee Bonus - 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

 

Write an SQL query to report the name and bonus amount of each employee with a bonus less than 1000.

 

# 1
SELECT name, bonus
FROM Employee E LEFT JOIN Bonus B USING(empID)
WHERE bonus < 1000 or bonus IS NULL;
# 2
SELECT name, bonus
FROM Employee LEFT JOIN Bonus USING(empId)
WHERE COALESCE(bonus, 0) < 1000;

댓글