[PRO] 조건에 맞는 사용자와 총 거래금액 조회하기 - Lv3

vvo_ter·2023년 10월 30일
0

SQL 고득점 Kit

목록 보기
5/24
post-custom-banner

💻 SQL 고득점 Kit > GROUP BY > 문제

문제 조건 놓치지 않기


👉 제출 코드

MYSQL

SELECT U.USER_ID, U.NICKNAME, SUM(B.PRICE) AS TOTAL_SALES
FROM USED_GOODS_BOARD AS B 
	JOIN USED_GOODS_USER AS U
ON B.WRITER_ID = U.USER_ID
WHERE B.STATUS = 'DONE'
GROUP BY U.USER_ID
HAVING SUM(B.PRICE) >= 700000
ORDER BY TOTAL_SALES ASC

ORACLE

SELECT U.USER_ID, U.NICKNAME, SUM(B.PRICE) AS TOTAL_SALES
FROM USED_GOODS_BOARD B 
    JOIN USED_GOODS_USER U
ON B.WRITER_ID = U.USER_ID
WHERE B.STATUS = 'DONE'
GROUP BY U.USER_ID, NICKNAME
HAVING SUM(B.PRICE) >= 700000
ORDER BY TOTAL_SALES ASC;
profile
's Coding Memory
post-custom-banner

0개의 댓글