Write a solution to:
February 2020
. In case of a tie, return the lexicographically smaller movie name.The result format is in the following example.
UNION
으로 묶어야 한다는 생각은 했는데.UNION ALL
은 중복행을 같이 보여주기 때문에 UNION ALL
사용(SELECT U.name as results FROM Users as U
JOIN MovieRating as M ON U.user_id = M.user_id
GROUP BY U.name
ORDER BY COUNT(*) DESC, U.name
LIMIT 1)
UNION ALL
(SELECT M.title as results FROM Movies as M
JOIN MovieRating as MR ON M.movie_id = MR.movie_id
WHERE MR.created_at LIKE '2020-02%'
GROUP BY M.title
ORDER BY AVG(MR.rating) DESC, M.title
LIMIT 1)