From cabb592bf48507b8b40cd591540772e382de3c52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Antonio=20Chac=C3=B3n=20Guti=C3=A9rrez?= <138903866+joseantoniochacon@users.noreply.github.com> Date: Thu, 3 Oct 2024 15:22:59 -0600 Subject: [PATCH] Time: 1398 ms (19.54%), Space: 0B (100.00%) - LeetHub --- 1341-movie-rating/1341-movie-rating.sql | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 1341-movie-rating/1341-movie-rating.sql diff --git a/1341-movie-rating/1341-movie-rating.sql b/1341-movie-rating/1341-movie-rating.sql new file mode 100644 index 0000000..61b7ea0 --- /dev/null +++ b/1341-movie-rating/1341-movie-rating.sql @@ -0,0 +1,5 @@ +# Write your MySQL query statement below + +(SELECT name AS results FROM (SELECT name, count(*) as rated_movies FROM MovieRating LEFT JOIN Users ON Users.user_id = MovieRating.user_id GROUP BY name ORDER BY rated_movies DESC, name) RATINGS LIMIT 1) +UNION ALL +(SELECT title AS results FROM (SELECT title, ROUND(AVG(rating),2) AS average_rating FROM MovieRating LEFT JOIN Movies ON Movies.movie_id = MovieRating.movie_id WHERE MONTH(created_at) = 2 AND YEAR(created_at) = 2020 GROUP BY title ORDER BY average_rating DESC, title) RATES LIMIT 1) \ No newline at end of file