You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Find the name of the user who has rated the greatest number of movies. In case of a tie, return the lexicographically smaller user name.
13
+
* Find the movie name with the *highest average* rating in `February 2020`. In case of a tie, return the lexicographically smaller movie name. [[Full Description](https://leetcode.com/problems/movie-rating/description/)]
14
+
15
+
## Submitted Solution
16
+
17
+
```sql
18
+
-- Submitted Solution
19
+
WITH cte1 AS (
20
+
SELECT
21
+
mr.user_id
22
+
,u.name
23
+
,COUNT(mr.rating) AS count_ratings
24
+
FROM MovieRating AS mr
25
+
JOIN Users u ONmr.user_id=u.user_id
26
+
GROUP BYmr.user_id
27
+
ORDER BY count_ratings DESC, u.nameASC
28
+
LIMIT1
29
+
),
30
+
cte2 AS (
31
+
SELECT
32
+
mr.movie_id
33
+
,mv.title
34
+
,AVG(mr.rating) AS avg_rating
35
+
,mr.created_at
36
+
FROM MovieRating AS mr
37
+
JOIN Movies mv ONmr.movie_id=mv.movie_id
38
+
WHERE EXTRACT(YEAR FROMmr.created_at) =2020AND EXTRACT(MONTH FROMmr.created_at) =2
0 commit comments