[문제]
[MySQL]
WITH Rating AS (
SELECT m.*
, u.*
, mr.rating
, mr.created_at
FROM MovieRating AS mr
LEFT JOIN Movies AS m ON mr.movie_id = m.movie_id
LEFT JOIN Users AS u ON mr.user_id = u.user_id
)
(SELECT name AS results
FROM Rating
GROUP BY user_id
ORDER BY COUNT(*) DESC, name ASC
LIMIT 1)
UNION ALL
(SELECT title AS results
FROM Rating
WHERE created_at >= '2020-02-01'
AND created_at < '2020-03-01'
GROUP BY movie_id
ORDER BY AVG(rating) DESC, title ASC
LIMIT 1)
'SQL > LeetCode' 카테고리의 다른 글
| [LeetCode] 1393. Capital Gain/Loss (0) | 2025.02.20 |
|---|---|
| [LeetCode] 1378. Replace Employee ID With The Unique Identifier (0) | 2025.02.20 |
| [LeetCode] 1327. List the Products Ordered in a Period (0) | 2025.02.20 |
| [LeetCode] 1321. Restaurant Growth (0) | 2025.02.20 |
| [LeetCode] 1280. Students and Examinations (0) | 2025.02.20 |
