커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
subquery에 group by 사용하기
엑셀보다 쉽고 빠른 SQL v0
4주차
북마크
김*원
댓글
2
추천
0
조회수
21
조회수
21
답변 완료

4주차 2번 강의보고, subquery 이용해서 음식타입별 평균금액에 따라 가중치(상중하)를 주는걸 해보고 있는데,

아래와 같이 subquery 쓰고, 각 cuisine_type 별로 상중하를 보려고 하니 저렇게 Korean 만 보여지네요 ㅠㅠ

group by cuisine_type했는데도 왜 안되는걸까요?


avg(price)를 지우니까, cuisine_type별로 다 보이긴하는데..


스파르타 즉문즉답


select case when food_type>18000 then '상'

when food_type between 15000 and 18000 then '중'

when food_type<15000 then '하'

end

food_type, cuisine_type, avg(price)

from

(

select price, cuisine_type , avg(price) food_type

from food_orders fo2

group by cuisine_type

) a

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