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



제가 처음에 답안을 작성했을 때는 Japanese 의 10대 결과값이 49, 20대 결과값이 52, 30대 결과값이 35로 나와서 제가 작성한 코드가 잘못되었다고 생각했는데 HW5 정답코드에 있는 내용을 복사해도 같은 값이 나와서 결과물 예시와 같은 값이 나오기 위해서는 코드의 어느 부분 수정이 필요할까요??



제 결과


강의 결과 예시




작성한 코드 및 에러 메세지

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 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) cnt_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



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