
* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.
* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.
결과물 예시랑 sql 쿼리를 해보니 다른 값이 나와서 질문드립니다. 어디가 잘못 되었는지 영 모르겠네요


결과물 예시에 'American' 50대가 56개가 잡히는데
SELECT * from food_orders f inner join customers c on f.customer_id = c.customer_id where age BETWEEN 50 and 59 and f.cuisine_type = 'American'
위에 쿼리를 이용해 검색해보니 59개가 검색이 됩니다. 잘 이해가 되지 않습니다
작성한 코드 및 에러 메세지
select cuisine_type,
max(if(age='10', cnt_order, 0)) "10대",
max(if(age='20', cnt_order, 0)) "20대",
max(if(age='30', cnt_order, 0)) "30대",
max(if(age='40', cnt_order, 0)) "40대",
max(if(age='50', cnt_order, 0)) "50대"
from
(
SELECT f.cuisine_type,
case when c.age between 10 and 19 then 10
when c.age between 20 and 29 then 20
when c.age between 30 and 39 then 30
when c.age between 40 and 49 then 40
else 50
end age,
count(1) cnt_order
from food_orders f inner join customers c on f.customer_id = c.customer_id
where c.age BETWEEN 10 and 59 group by 1,2
) a
group by 1
