now is better than never

[Level 4][SELECT] 서울에 위치한 식당 목록 출력하기 본문

프로그래머스/SQL

[Level 4][SELECT] 서울에 위치한 식당 목록 출력하기

김초송 2023. 1. 4. 17:21

https://school.programmers.co.kr/learn/courses/30/lessons/131118?language=oracle 

 

<Oracle>

with score as
(select inf.rest_id, round(avg(rev.review_score), 2) score
 from rest_info inf join
      rest_review rev
      on inf.rest_id = rev.rest_id
 group by inf.rest_id)

SELECT inf.rest_id, inf.rest_name, inf.food_type
     , inf.favorites, inf.address
     , to_char(s.score, '999.99') score
from rest_info inf join
     score s
     on inf.rest_id = s.rest_id
where substr(inf.address, 1, 2) = '서울'
order by s.score desc, inf.favorites desc;

 

- 문제

- 실행결과

 

근데 SCORE 출력을 저렇게 하라고 해놓고선...

그냥 to_char 안하고 s.score 해도 (숫자형이라 맨 끝에 0 지워지는데) 정답처리 되긴 함 

그래도 난 너무 신경쓰여 ㅋㅋㅋㅋㅋㅋ ㅠㅠㅠ