[PRO] 카테고리 별 도서 판매량 집계하기 - Lv3

vvo_ter·2023년 11월 11일
0

SQL 고득점 Kit

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

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


👉 제출 코드

MySQL

SELECT CATEGORY, SUM(S.SALES) TOTAL_SALES
FROM BOOK JOIN (
    SELECT BOOK_ID, SALES
    FROM BOOK_SALES
    WHERE SALES_DATE LIKE '2022-01%') S
    ON BOOK.BOOK_ID = S.BOOK_ID
GROUP BY CATEGORY
ORDER BY CATEGORY

Oracle

SELECT CATEGORY, SUM(S.SALES) TOTAL_SALES
FROM BOOK JOIN (
    SELECT BOOK_ID, SALES
    FROM BOOK_SALES
    WHERE TO_CHAR(SALES_DATE, 'YYYY-MM') LIKE '2022-01') S
    ON BOOK.BOOK_ID = S.BOOK_ID
GROUP BY CATEGORY
ORDER BY CATEGORY
profile
's Coding Memory
post-custom-banner

0개의 댓글