https://school.programmers.co.kr/learn/courses/30/lessons/131124
정답
SELECT A.MEMBER_NAME,B.REVIEW_TEXT,TO_CHAR(B.REVIEW_DATE,'YYYY-MM-DD') REVIEW_DATE
FROM MEMBER_PROFILE A
INNER JOIN REST_REVIEW B
ON A.MEMBER_ID = B.MEMBER_ID
WHERE A.MEMBER_ID IN (
SELECT MEMBER_ID
FROM REST_REVIEW
GROUP BY MEMBER_ID
HAVING COUNT(*) =(
SELECT MAX(COUNT(*))
FROM REST_REVIEW
GROUP BY MEMBER_ID
)
)
ORDER BY REVIEW_DATE,B.REVIEW_TEXT
풀이
가장 많은 MEMBER_ID 횟수 구하기
SELECT MEMBER_ID,COUNT(*)
FROM REST_REVIEW
GROUP BY MEMBER_ID
SELECT MAX(COUNT(*))
FROM REST_REVIEW
GROUP BY MEMBER_ID
SELECT MEMBER_ID
FROM REST_REVIEW
GROUP BY MEMBER_ID
HAVING COUNT(*) =(
SELECT MAX(COUNT(*))
FROM REST_REVIEW
GROUP BY MEMBER_ID
)
SELECT A.MEMBER_NAME,B.REVIEW_TEXT,TO_CHAR(B.REVIEW_DATE,'YYYY-MM-DD') REVIEW_DATE
FROM MEMBER_PROFILE A
INNER JOIN REST_REVIEW B
ON A.MEMBER_ID = B.MEMBER_ID
WHERE A.MEMBER_ID IN (
SELECT MEMBER_ID
FROM REST_REVIEW
GROUP BY MEMBER_ID
HAVING COUNT(*) =(
SELECT MAX(COUNT(*))
FROM REST_REVIEW
GROUP BY MEMBER_ID
)
)
ORDER BY REVIEW_DATE,B.REVIEW_TEXT
'DB > 프로그래머스' 카테고리의 다른 글
[Oracle] 식품분류별 가장 비싼 식품의 정보 조회하기 (0) | 2024.10.11 |
---|---|
[Oracle] 5월 식품들의 총매출 조회하기 (0) | 2024.10.10 |
[Oracle] 오프라인/온라인 판매 데이터 통합하기 (0) | 2024.10.06 |
[Oracle] 취소되지 않은 진료 예약 조회하기 (0) | 2024.10.02 |
[Oracle] 주문량이 많은 아이스크림들 조회하기 (0) | 2024.09.28 |