-- 코드를 입력하세요

SELECT A.REST_ID, REST_NAME, FOOD_TYPE, FAVORITES, ADDRESS, ROUND(AVG(B.REVIEW_SCORE), 2) AS SCORE
FROM REST_INFO AS A, REST_REVIEW AS B
WHERE
    LEFT(SUBSTRING_INDEX(TRIM(ADDRESS), ' ', 1),2) = '서울'
    AND A.REST_ID = B.REST_ID
GROUP BY A.REST_ID
ORDER BY SCORE DESC, FAVORITES DESC