즐겨찾기가 가장 많은 식당 정보 출력하기
https://school.programmers.co.kr/learn/courses/30/lessons/131123
- 문제 풀이
1
2
3
4
5
6
7
8
SELECT F.FOOD_TYPE, I.REST_ID, I.REST_NAME, F.FAVORITES
FROM (SELECT FOOD_TYPE, MAX(FAVORITES) AS "FAVORITES"
FROM REST_INFO
GROUP BY FOOD_TYPE) F
JOIN REST_INFO I
ON F.FOOD_TYPE = I.FOOD_TYPE
WHERE F.FAVORITES = I.FAVORITES
ORDER BY F.FOOD_TYPE DESC;
1
2
3
4
5
6
7
8
9
10
11
SELECT I.FOOD_TYPE,
I.REST_ID,
I.REST_NAME,
I.FAVORITES
FROM
(SELECT DISTINCT FOOD_TYPE, MAX(FAVORITES) AS "FAVORITES"
FROM REST_INFO
GROUP BY FOOD_TYPE) F, REST_INFO I
WHERE F.FOOD_TYPE = I.FOOD_TYPE
AND F.FAVORITES = I.FAVORITES
ORDER BY FOOD_TYPE DESC;
- 오답
- 실행 결과
이 기사는 저작권자의 CC BY 4.0 라이센스를 따릅니다.