SQL/GROUP BY
[프로그래머스 ORACLE SQL]조건에 맞는 사용자와 총 거래금액 조회하기★LEFT JOIN
goAhEAd_29
2023. 6. 22. 00:49
728x90
반응형
https://school.programmers.co.kr/learn/courses/30/lessons/164668
SELECT A.USER_ID , A.NICKNAME, SUM(B.PRICE) AS TOTAL_SALES FROM USED_GOODS_USER A LEFT JOIN
(SELECT * FROM USED_GOODS_BOARD WHERE STATUS = 'DONE') B
ON A.USER_ID = B.WRITER_ID
GROUP BY A.USER_ID, A.NICKNAME
HAVING SUM(B.PRICE)>= 700000
ORDER BY SUM(B.PRICE)
==> FROM 절 서브쿼리, LEFT JOIN
728x90
반응형