[SQL#115]1341. Movie Rating

Gi Woon Lee·2024년 9월 2일

SQL

목록 보기
13/33

1341. Movie Rating

# Users + MovieRating
# 가장 많은 영화를 평가한 user의 name을 구하라. 동점이면 알파벳 오름차순 첫 번째 
(select name as results
from MovieRating join Users using (user_id)
group by name
order by count(*) desc, name
limit 1)

union all 

# Movie + MovieRating
# February 2020에 가장 높은 평균 평점을 받은 movie title를 구하라. 동점이면 알파벳 오름차순 첫 번째

(select title as results
from MovieRating join Movies using (movie_id)
where created_at like "2020-02%"
group by title
order by avg(rating) desc, title asc
limit 1);

order by에 집계함수가 들어간다오..

0개의 댓글