๐ข ๋ณธ ํฌ์คํ ์ ํ์ฉ๋๋ ๊ธฐ๋ณธ ๋ฌธ์ ๋ฐ ์๋ฃ ์ถ์ฒ๋
๋ฆฌํธ์ฝ๋ Problems, https://leetcode.com/problemset/all/์์ ๋ฐํ๋๋ค.
โ ๋ฌธ์
https://leetcode.com/problems/employee-bonus/
Table : Employee
Table : Bonus
Write an SQL query to report the name and bonus amount of each employee with a bonus less than 1000.
Return the result table in any order.
The query result format is in the following example.
โ ํ์ด
๋ฌธ์ ์๊ตฌ์ฌํญ
๊ทผ๋ก์ ์ด๋ฆ๊ณผ ๋ณด๋์ค๋ฅผ ์ถ๋ ฅํ๋๋ฐ ๋ณด๋์ค๊ฐ 1000 ๋ฏธ๋ง์ธ
์ถ๋ ฅ(์ ๋ ฌ) ์์๋ ์๊ด ์์.
์ถ๋ ฅ ์์ ๊ฒฐ๊ณผ๋ฅผ ๋ณด๋ฉด, bonus๊ฐ ์๋ ๊ทผ๋ก์๋ค์ null๋ก ์ถ๋ ฅ๋์ด์ผ ํ๋ค.*
๋ฐ๋ผ์
์กฐ๊ฑดโ *Employee ํ ์ด๋ธ ๊ธฐ์ค์ผ๋ก Bonus ํ ์ด๋ธ์ left join ํด์ค๋ค.
์กฐ๊ฑดโก ๋ณด๋์ค๊ฐ 1000 ๋ฏธ๋ง์ ์กฐ๊ฑด์ผ๋ก ์ค์ ํ๋ค.
(์ค์ํ ์ : ๋ณด๋์ค๊ฐ ์๋ ์ง์๋ 1000 ๋ฏธ๋ง์ ํด๋นํ๋ฏ๋ก bonus์ปฌ๋ผ์ด null๊ฐ์ธ ๊ทผ๋ก์๋ ์กฐ๊ฑด์
OR ์กฐ๊ฑด์ผ๋ก ๋ฃ์ด์ฃผ์ด์ผ ํ๋ค.)
SELECT T1.name, T2.bonus
FROM Employee T1
LEFT JOIN Bonus T2
ON T1.empId = T2.empId
WHERE T2.bonus < 1000 OR T2.bonus is null
'Growth ๐ณ > Practice ๐ป' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[LeetCode] 602. Friend Requests II: Who Has the Most Friends (0) | 2023.05.12 |
---|---|
[LeetCode] 601. Human Traffic of Stadium (0) | 2023.05.11 |
[LeetCode] 585. Investments in 2016 (0) | 2023.05.09 |
[LeetCode] 570. Managers with at Least 5 Direct Reports (0) | 2023.04.24 |
[LeetCode] 550. Game Play Analysis IV (0) | 2023.04.21 |