커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
5주차 숙제 질문드립니다.
엑셀보다 쉽고 빠른 SQL
5주차
북마크
류*철
댓글
1
추천
0
조회수
24
조회수
24
답변 완료

5주차 숙제를 하고있는데 미묘한 값의 차이가 있어서 문의드립니다.


select cuisine_type,

max(if(age_group=10,cnt_order,0)) '10대',

max(if(age_group=20,cnt_order,0)) '20대',

max(if(age_group=30,cnt_order,0)) '30대',

max(if(age_group=40,cnt_order,0)) '40대',

max(if(age_group=50,cnt_order,0)) '50대'

from

(

select f.cuisine_type ,c.age,

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

when c.age between 50 and 59 then 50 end age_group,

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,3

) a

group by 1



전체 화면 캡처보고

스파르타 즉문즉답스파르타 즉문즉답


어디서 조건을 잘못 건걸까요?






취소
 공유
취소
댓글 0
댓글 알림
나의얼굴