출처: https://astrocosmos.tistory.com/202 [ASTROCOSMOS:티스토리] SQL GROUP BY] 조건에 맞는 사용자와 총 거래금액 조회하기 :: 하나둘셋넷
728x90

SQL GROUP BY] 조건에 맞는 사용자와 총 거래금액 조회하기

 

-- 코드를 입력하세요
SELECT u.USER_ID,	u.NICKNAME,	SUM(b.PRICE) as TOTAL_SALES
    FROM USED_GOODS_BOARD b # 중고 거래 게시판
    INNER JOIN USED_GOODS_USER u on u.USER_ID = b.WRITER_ID
    WHERE b.STATUS = 'DONE'
    GROUP BY u.USER_ID, u.NICKNAME
    HAVING SUM(b.PRICE) >= 700000
    ORDER BY TOTAL_SALES ASC
728x90

+ Recent posts