Oracle
[프로그래머스] 저자 별 카테고리 별 매출액 집계하기
dearbeany
2023. 11. 25. 03:15
문제 잘못(내림차순) 나와있다.. author_id 는 오름차순으로 정렬해야 통과됨~
select a.author_id, a.author_name, c.category, c.total_sales
from author a,
(select b.author_id, b.category, sum(b.price* s.sales) as total_sales
from book b,
(select book_id, sum(sales) sales
from book_sales
where to_char(sales_date, 'yyyy-mm') ='2022-01'
group by book_id) s
where b.book_id = s.book_id
group by author_id, category) c
where a.author_id = c.author_id
order by 1, 3 desc;