출처: https://astrocosmos.tistory.com/202 [ASTROCOSMOS:티스토리] SQL GROUP BY] 카테고리 별 도서 판매량 집계하기 :: 하나둘셋넷
728x90

SQL GROUP BY] 카테고리 별 도서 판매량 집계하기

 

-- 코드를 입력하세요
SELECT b.CATEGORY, sum(s.SALES) as TOTAL_SALES
    FROM BOOK b
    INNER JOIN(
        SELECT BOOK_ID, SALES, SALES_DATE
        FROM BOOK_SALES
    ) as s on b.BOOK_ID = s.BOOK_ID
    WHERE s.SALES_DATE >= '2022-01-01' AND s.SALES_DATE < '2022-02-01'
    GROUP BY b.CATEGORY
    ORDER BY b.CATEGORY

 

728x90

+ Recent posts