문제
'Hotel Arena'에 대해 각 리뷰 점수별로 몇 개의 리뷰가 있는지 찾으세요. 호텔 이름('Hotel Arena'), 각 리뷰 점수, 해당 점수에 대한 리뷰 개수를 출력하세요. 결과에는 'Hotel Arena'만 포함되도록 하세요.
테이블설명

예상결과

✏️ 풀이
SELECT hotel_name, reviewer_score, COUNT(*) AS `count`
FROM hotel_reviews
WHERE hotel_name = 'Hotel Arena'
GROUP BY hotel_name, reviewer_score;
'Hotel Arena'의 리뷰 점수별로 리뷰수를 COUNT()를 해야하기 때문에
GROUP BY 절에 hotel_name, reviewer_score 두 개의 컬럼 명을 넣어준다.
'[코딩테스트] > [SQL]' 카테고리의 다른 글
[StrataScratch - SQL] (Easy) Find all posts which were reacted to with a heart (0) | 2025.04.17 |
---|---|
[StrataScratch - SQL] (Easy) Abigail Breslin Nominations (0) | 2025.04.17 |
[StrataScratch - SQL] (Easy) Bikes Last Used (0) | 2025.04.16 |
[StrataScratch - SQL] (Easy) Salaries Differences (0) | 2025.04.15 |
[StrataScratch - SQL] (Easy) Finding Updated Records (0) | 2025.04.15 |