g1301_1400.s1341_movie_rating.script.sql Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of leetcode-in-java Show documentation
Show all versions of leetcode-in-java Show documentation
Java-based LeetCode algorithm problem solutions, regularly updated
# Write your MySQL query statement below
# #Medium #Database #2023_08_16_Time_2515_ms_(78.94%)_Space_0B_(100.00%)
(SELECT name results
FROM Users as U, MovieRating as MR
WHERE U.user_id = MR.user_id
GROUP BY U.user_id
ORDER BY COUNT(MR.user_id) DESC, name ASC LIMIT 1)
UNION ALL
(SELECT title results
FROM Movies as M, MovieRating as MR
WHERE M.movie_id = MR.movie_id AND created_at BETWEEN '2020-02-01' AND '2020-02-29'
GROUP BY M.movie_id
ORDER BY AVG(rating) DESC, title ASC LIMIT 1)