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

* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.

* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.


하기 코드로 과제를 풀고, 추출을 했는데 계속 오류가 발생합니다. 답안지랑 비교해봐도 다른 부분은 평균 가격과 평균 나이의 명칭을 다르게 한 것 밖에 없는 것 같은데 어디서 오류가 발생하는건지 확인 부탁드립니다ㅠㅠ



스파르타 즉문즉답




작성한 코드 및 에러 메세지

select f.restaurant_name,

       case when avg_price<=5000 then 'price_case1',

            when avg_price>5000 and avg_price<=10000 then 'price_case2',

            when avg_price>10000 and avg_price<=30000 then 'price_case3',

            when avg_price>30000 then 'price_case4' end price_case

       case when avg_age<=29 then 'age_case1',

            when avg_age>30 and avg_age<=39 then 'age_case2',

            when avg_age>40 and avg_age<=49 then 'age_case3',

            when avg_age>=50 then 'age_case4' end age_case

from 

(

select a.restaurant_name

       avg(price) avg_price

       avg(age) avg_age

from food_orders f inner join customers c on f.customer_id=c.customer_id

group by 1

) a

order by 1

SQL Error [1064] [42000]: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ',

      when avg_price>5000 and avg_price<=10000 then 'price_case2',

   ' at line 2


Error position: line: 1



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