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

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

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


문제 중


SQL 실습 문제 중에 음식 단가, 음식 종류 별로 음식점 그룹 나누기 이런 문제가 있는데요

[실습] 음식 단가, 음식 종류 별로 음식점 그룹 나누기

  • (Korean = 한식 Japanese, Chinese, Thai, Vietnamese, Indian = 아시아식 그외 = 기타)
  • (가격 = 5000, 15000, 그 이상)


제가 만든 답안은


Select cuisine_type,
       price/quantity "단가",
       restaurant_name,
       order_id,
case when cuisine_type='Korean' then "한식"
     when cuisine_type='Japanese' or cuisine_type='Chinese' or cuisine_type='Thai' or cuisine_type='Vietnamese' or cuisine_type='Indian'
     then "아시아식"
     else "기타" end "음식점 종류",
case when price/quantity<5000 then 'Low'
     when price/quantity between 5000 and 15000 then 'Mid'
     when price/quantity>15000 then 'High' end "음식 가격"
from food_orders


그리고 해설에 나온 답은

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
댓글 알림
나의얼굴