
* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.
* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.
5주차 숙제 진행중, 제가 작성한 쿼리 결과값이 강의 자료의 값과 달라서
강의 자료 숙제 해설의 코드스니펫의 쿼리 결과값을 보니
저와 동일하게 나옵니다.
강의 자료의 결과값 수정이 필요할거 같습니다.

작성한 코드 및 에러 메세지
SELECT cuisine_type,
max(if(age='10대', count_order, 0)) '10대',
max(if(age='20대', count_order, 0)) '20대',
max(if(age='30대', count_order, 0)) '30대',
max(if(age='40대', count_order, 0)) '40대',
max(if(age='50대', count_order, 0)) '50대'
FROM
(
select f.cuisine_type,
case when age between 10 and 19 then '10대'
when age between 20 and 29 then '20대'
when age between 30 and 39 then '30대'
when age between 40 and 49 then '40대'
when age between 50 and 59 then '50대'
end age,
count(1) count_order
FROM food_orders f inner join customers c on f.customer_id = c.customer_id
WHERE age BETWEEN 10 and 59
GROUP by 1,2
) a
group by 1
----------------------------------------------------------------
select cuisine_type,
max(if(age=10, order_count, 0)) "10대",
max(if(age=20, order_count, 0)) "20대",
max(if(age=30, order_count, 0)) "30대",
max(if(age=40, order_count, 0)) "40대",
max(if(age=50, order_count, 0)) "50대"
from
(
select a.cuisine_type,
case when age between 10 and 19 then 10
when age between 20 and 29 then 20
when age between 30 and 39 then 30
when age between 40 and 49 then 40
when age between 50 and 59 then 50 end age,
count(1) order_count
from food_orders a inner join customers b on a.customer_id=b.customer_id
where age between 10 and 59
group by 1, 2
) t
group by 1
