Skip to content

Commit b02ef66

Browse files
committed
Update 1341. Movie Rating.sql
1 parent 18559ef commit b02ef66

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

LeetCode SQL 50 Solution/1341. Movie Rating.sql

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
1341. Movie Rating
2-
Solved
3-
Medium
4-
Topics
5-
Companies
6-
SQL Schema
7-
Pandas Schema
2+
"""
83
Table: Movies
94
105
+---------------+---------+
@@ -95,4 +90,26 @@ Explanation:
9590
Daniel and Monica have rated 3 movies ("Avengers", "Frozen 2" and "Joker") but Daniel is smaller lexicographically.
9691
Frozen 2 and Joker have a rating average of 3.5 in February but Frozen 2 is smaller lexicographically.
9792
93+
"""
9894

95+
# Write your MySQL query statement below
96+
(
97+
SELECT name AS results
98+
FROM
99+
Users
100+
JOIN MovieRating USING (user_id)
101+
GROUP BY user_id
102+
ORDER BY COUNT(1) DESC, name
103+
LIMIT 1
104+
)
105+
UNION ALL
106+
(
107+
SELECT title
108+
FROM
109+
MovieRating
110+
JOIN Movies USING (movie_id)
111+
WHERE DATE_FORMAT(created_at, '%Y-%m') = '2020-02'
112+
GROUP BY movie_id
113+
ORDER BY AVG(rating) DESC, title
114+
LIMIT 1
115+
);

0 commit comments

Comments
 (0)