본문 바로가기

algorithm

[programmers] MySQL - Lv.4 서울에 위치한 식당 목록 출력하기 (select)

문제

 

 

 

 

풀이

 

SELECT a.rest_id, a.rest_name, a.food_type, a.favorites, a.address, b.score
from rest_info a join (select rest_id, round(avg(review_score), 2) score
                       from rest_review
                       group by rest_id) b
on a.rest_id = b.rest_id
where a.address like '서울%'
order by b.score desc, a.favorites desc;