커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
concat과 if를 활용한 case when 단순화
[왕초보] 엑셀보다 쉽고 빠른 SQL v0
3주차
북마크
장*민
댓글
3
추천
0
조회수
7
조회수
7
답변 완료

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

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


case when 대신 concat과 if 를 사용해 명령어 자체를 좀 단순화하고 싶은데 아래 명령어에서 잘못된 부분은 어디고 이런 방식으로 구현은 가능한가요?

select restaurant_name,

cuisine_type ,

price/quantity "단가",

concat(case when cuisine_type ='Korean' then '한식', when cuisine_type in ('Japanese', 'Indian', 'Chinese', 'Vietnamese', 'Thai') then '아시안', when cuisine_type not in ('Korean', 'Japanese', 'Indian', 'Chinese', 'Vietnamese', 'Thai') then '기타' end, if(price/quantity<5000, 1, if(15000>price/quantity>=5000, 2, 3))) '식당그룹'

from food_orders


스파르타 즉문즉답







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