커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
3-5 실습2번 between 절 질문
엑셀보다 쉽고 빠른 SQL
3주차
북마크
김*은
댓글
3
추천
0
조회수
14
조회수
14
답변 완료

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

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


1주차 강의 내용에 BETWEEN A and B 의 경우 A 와 B 사이라고 알려주셔서

A 이상 B 이하에 해당하는 구간을 지칭하는 것으로 이해했습니다.


3-5 실습2번 문제에는 가격 = 5000 미만, 5000 이상 15000 미만, 15000 이상 으로 그룹 나누기로 되어 있는데 


작성된 코드와 강의 중 선생님 설명은 5000 미만, 5000 이상 15000 이하, 15000 초과로 되어있습니다. 


문제와 같이 5000 미만, 5000 이상 15000 미만, 15000 이상으로 구분된 조건절은 어떻게 작성하면 되나요? 





코드스니펫 코드

select restaurant_name,
       price/quantity "단가",
       cuisine_type,
       order_id,
       case when (price/quantity <5000) and cuisine_type='Korean' then '한식1'
            when (price/quantity between 5000 and 15000) and cuisine_type='Korean' then '한식2'
            when (price/quantity > 15000) and cuisine_type='Korean' then '한식3'
            when (price/quantity <5000) and cuisine_type in ('Japanese', 'Chinese', 'Thai', 'Vietnamese', 'Indian') then '아시아식1'
            when (price/quantity between 5000 and 15000) and cuisine_type in ('Japanese', 'Chinese', 'Thai', 'Vietnamese', 'Indian') then '아시아식2'
            when (price/quantity > 15000) and cuisine_type in ('Japanese', 'Chinese', 'Thai', 'Vietnamese', 'Indian') then '아시아식3'
            when (price/quantity <5000) and cuisine_type not in ('Korean', 'Japanese', 'Chinese', 'Thai', 'Vietnamese', 'Indian') then '기타1'
            when (price/quantity between 5000 and 15000) and cuisine_type not in ('Korean', 'Japanese', 'Chinese', 'Thai', 'Vietnamese', 'Indian') then '기타2'
            when (price/quantity > 15000) and cuisine_type not in ('Korean', 'Japanese', 'Chinese', 'Thai', 'Vietnamese', 'Indian') then '기타3' end "식당 그룹"
from food_orders



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