그룹별 조건에 맞는 식당 목록 출력하기
https://school.programmers.co.kr/learn/courses/30/lessons/131124
- 문제 풀이
1
2
3
4
5
6
7
8
9
10
11
12
13
SELECT M.MEMBER_NAME, R.REVIEW_TEXT, TO_CHAR(R.REVIEW_DATE, 'YYYY-MM-DD') AS "REVIEW_DATE"
FROM (
SELECT MEMBER_ID, COUNT(*) AS "COUNT"
FROM REST_REVIEW
GROUP BY MEMBER_ID
ORDER BY COUNT DESC
FETCH FIRST 1 ROWS ONLY
) C
JOIN MEMBER_PROFILE M
ON C.MEMBER_ID = M.MEMBER_ID
JOIN REST_REVIEW R
ON C.MEMBER_ID = R.MEMBER_ID
ORDER BY REVIEW_DATE, R.REVIEW_TEXT;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
SELECT
M.MEMBER_NAME,
R.REVIEW_TEXT,
TO_CHAR(R.REVIEW_DATE, 'YYYY-MM-DD') AS "REVIEW_DATE"
FROM
REST_REVIEW R
JOIN
MEMBER_PROFILE M
ON
R.MEMBER_ID = M.MEMBER_ID
WHERE
M.MEMBER_ID = (
SELECT
MEMBER_ID
FROM
REST_REVIEW
GROUP BY
MEMBER_ID
ORDER BY
COUNT(*) DESC
FETCH FIRST 1 ROWS ONLY
)
ORDER BY
R.REVIEW_DATE,
R.REVIEW_TEXT;
- 실행 결과
이 기사는 저작권자의 CC BY 4.0 라이센스를 따릅니다.