SELECT
ii.ingredient_type
, SUM(total_order) AS TOTAL_ORDER
FROM
first_half fh
LEFT JOIN icecream_info ii
USING (flavor)
GROUP BY
ii.ingredient_type
ORDER BY
TOTAL_ORDER
;
ingredient_type
컬럼이 하나뿐이라 alias 표시를 안 해도 괜찮을 것 같음fh.total_order
로 적는 편이 좋지 않았을까 하는 생각LEFT (OUTER) JOIN
을 사용했는데 다른 분들 풀이를 보면 (INNER) JOIN
을 사용하고 있음SELECT ingredient_type, SUM(total_order) AS TOTAL_ORDER
FROM first_half JOIN icecream_info USING (flavor)
GROUP BY 1
ORDER BY 2
;
※추가: OUTER JOIN
SELECT ii.ingredient_type , SUM(total_order) AS TOTAL_ORDER FROM first_half fh LEFT JOIN icecream_info ii ON fh.flavor <> ii.flavor