๐ป ๋ฌธ์ ์ฃผ์ : Not Boring Movies - LeetCode
Not Boring Movies - LeetCode
Can you solve this real interview question? Not Boring Movies - Table: Cinema +----------------+----------+ | Column Name | Type | +----------------+----------+ | id | int | | movie | varchar | | description | varchar | | rating | float | +----------------
leetcode.com
๐ป ๋ฌธ์
Write a solution to report the movies with an odd-numbered ID and a description that is not 'boring'. Return the result table ordered by rating in desceding order.
- ํ์ ID๊ฐ ๋ณธ ์ํ ๋ฐ ์ค๋ช ๋ฑ ์ ๋ณด๋ฅผ ์ถ๋ ฅํ์์ค. ์ค๋ช ์ 'boring'์ด ์๋์ด์ผ ํ๋ฉฐ, ๊ฒฐ๊ณผ ํ ์ด๋ธ์ rating์ ๊ธฐ์ค์ผ๋ก ๋ด๋ฆผ์ฐจ์ ์ ๋ ฌํด์ผ ํฉ๋๋ค.
๐ป ์ฝ๋ ๋ฐ ํ์ด
select id, movie, description, rating
from Cinema
where mod(id, 2) = 1 and description != 'boring'
order by rating desc
โ Mod(N, M)
Mod ํจ์๋ ์ด๋ ํ ์ N์ M์ผ๋ก ๋๋ ๋๋จธ์ง๋ฅผ ์ถ๋ ฅํ๋ ํจ์๋ก, ํ์ง์ ๊ตฌ๋ถํ ๋ ๋ง์ด ์ด๋ค. Mod ํจ์๋ Mod(N, M) ํ์ ์ธ์๋ ๊ธฐ์กด C ์ธ์ด ๋ฑ์์ ์ฌ์ฉํ๋ 'N % M' ํ์์ผ๋ก๋ ์ฌ์ฉ ๊ฐ๋ฅํ๋ค.
'SQL > LeetCode' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[LeetCode][SQL50] #17. Project Employees I (0) | 2023.11.15 |
---|---|
[LeetCode][SQL50] #16. Average Selling Price (0) | 2023.11.14 |
[LeetCode][SQL50] #14. Confirmation Rate (0) | 2023.11.13 |
[LeetCode][SQL50] #13. Managers with at Least 5 Direct Reports (0) | 2023.11.09 |
[LeetCode][SQL50] #12. Students and Examinations (0) | 2023.11.09 |