- Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy path_1341.sql
19 lines (19 loc) · 587 Bytes
/
_1341.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
--# Write your MySQL query statement below
SELECT user_name AS results FROM
(
SELECTa.nameAS user_name, COUNT(*) AS counts FROM Movie_Rating AS b
JOIN Users AS a
ona.user_id=b.user_id
GROUP BYb.user_id
ORDER BY counts DESC, user_name ASCLIMIT1
) first_query
UNION
SELECT movie_name AS results FROM
(
SELECTc.titleAS movie_name, AVG(d.rating) AS rate FROM Movie_Rating AS d
JOIN Movies AS c
onc.movie_id=d.movie_id
WHERE substr(d.created_at, 1, 7) ='2020-02'
GROUP BYd.movie_id
ORDER BY rate DESC, movie_name ASCLIMIT1
) second_query;