[프로그래머스SQL]주문량이 많은 아이스크림들 조회하기

allnight5·2023년 7월 24일
0

프로그래머스SQL

목록 보기
19/19

링크

JOIN

SELECT J.FLAVOR FROM JULY AS J 
LEFT JOIN FIRST_HALF AS F
ON F.SHIPMENT_ID = J.SHIPMENT_ID
GROUP BY J.FLAVOR
ORDER BY SUM(J.TOTAL_ORDER)+F.TOTAL_ORDER DESC
LIMIT 3

UNION

select FLAVOR
from 
    (SELECT *
    from FIRST_HALF
    union
    SELECT *
    from JULY) a

group by FLAVOR
order by SUM(TOTAL_ORDER) desc
limit 3
profile
공부기록하기

0개의 댓글