본문 바로가기

algorithm

[programmers] MySQL - Lv.4 5월 식품들의 총매출 조회하기 (join)

문제

 

 

 

풀이

 

select a.product_id, a.product_name, sum(b.amount) * a.price total_sales
from food_product a join food_order b
on a.product_id = b.product_id
where month(b.produce_date) = 5
group by a.product_id
order by total_sales desc, a.product_id