Skip to content

Latest commit

 

History

History
24 lines (20 loc) · 813 Bytes

README.md

File metadata and controls

24 lines (20 loc) · 813 Bytes

GROUP BY

SELECT CATEGORY, SUM(SALES) AS TOTAL_SALES
FROM BOOK_SALES JOIN BOOK
ON BOOK_SALES.BOOK_ID = BOOK.BOOK_ID
WHERE SALES_DATE BETWEEN '2022-01-01' AND '2022-01-31'
GROUP BY CATEGORY
ORDER BY CATEGORY ASC
SELECT BOOK.AUTHOR_ID, AUTHOR_NAME, CATEGORY, SUM(SALES * PRICE) AS TOTAL_SALES
FROM BOOK_SALES 
JOIN BOOK ON BOOK.BOOK_ID = BOOK_SALES.BOOK_ID
JOIN AUTHOR ON BOOK.AUTHOR_ID = AUTHOR.AUTHOR_ID
WHERE SALES_DATE BETWEEN '2022-01-01' AND '2022-01-31'
GROUP BY CATEGORY, AUTHOR_ID
ORDER BY AUTHOR_ID ASC, CATEGORY DESC