Notice
Recent Posts
Recent Comments
Link
«   2025/05   »
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

dearbeany

[프로그래머스] 저자 별 카테고리 별 매출액 집계하기 본문

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;