OkBublewrap

Average Review Ratings 본문

개발/SQL

Average Review Ratings

옥뽁뽁 2025. 3. 10. 00:24

Average Review Ratings

문제

  1. 평균 별점 월별 계산
  2. 출력: 월, 제품ID, 평균 별점
  3. 별점 소수점 둘째 자리
  4. 월별 정렬, 제품ID 정렬

 

풀이

select 
  extract(month from submit_date) as mth,
  product_id,
  round(avg(stars), 2) as avg_stars
from reviews
group by extract(month from submit_date), product_id
order by mth, product_id

1️⃣ group by: month 추출, product_id 별 평균평점 계산

2️⃣ order by: mth, product_id 정렬

'개발 > SQL' 카테고리의 다른 글

Odd and Even Measurements  (0) 2025.03.10
Well Paid Employees  (0) 2025.03.10
Supercloud Customer  (0) 2025.03.09
Signup Activation Rate  (0) 2025.03.09
Cities With Completed Trades  (0) 2025.03.09