Computer Science/데이터 베이스
[프로그래머스 - Oracle] 131118 - 서울에 위치한 식당 목록 출력하기
바보1
2023. 10. 21. 14:15
0. 문제 링크
https://school.programmers.co.kr/learn/courses/30/lessons/131118
1. 풀이 방법
- 위에는 where과 and를 사용하였고, 아래는 join과 having을 사용했다.
2. 코드
SELECT i.rest_id, i.rest_name, i.food_type, i.favorites, i.address, round(avg(r.review_score), 2) as score
from rest_info i, rest_review r
where i.rest_id = r.rest_id
and i.address like '서울%'
group by i.rest_id, i.rest_name, i.food_type, i.favorites, i.address
order by score desc, i.favorites desc
SELECT i.rest_id, i.rest_name, i.food_type, i.favorites, i.address, round(avg(r.review_score), 2) as score
from rest_info i join rest_review r on i.rest_id = r.rest_id
group by i.rest_id, i.rest_name, i.food_type, i.favorites, i.address
having i.address like '서울%'
order by score desc, i.favorites desc