SQL 고득점 Kit - JOIN Level4 - 5월 식품들의 총매출 조회하기 - mysql

Purple·2022년 10월 26일
0

sql

목록 보기
16/22

https://school.programmers.co.kr/learn/challenges?page=1&languages=mysql&order=recent

select product_id, product_name, price * amount as total_sales
from food_product
inner join(
    select product_id as product_id1, sum(amount) as amount
    from food_order
    where year(produce_date) = 2022 and month(produce_date) = 5
    group by product_id1
) join1 on food_product.product_id = product_id1
order by total_sales desc, product_id asc

select price * amount

profile
안녕하세요.

0개의 댓글