
* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.
* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.
제가 작성한 코드와 수업에서 설명된 코드가 다른데,
제가 작성한 코드의 문제점이 무엇인지 잘 모르겠어서 질문 남깁니다...!
위에가 수업에서 사용된 코드고 아래가 제가 작성한 코드입니다.
select restaurant_name,
price_per_plate*ratio_of_add "수수료"
from
(
select restaurant_name,
case when price_per_plate<5000 then 0.005
when price_per_plate between 5000 and 19999 then 0.01
when price_per_plate between 20000 and 29999 then 0.02
else 0.03 end ratio_of_add,
price_per_plate
from
(
select restaurant_name, avg(price/quantity) price_per_plate
from food_orders
group by 1
) a
) b

작성한 코드 및 에러 메세지
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 '단가<5000 then price*0.005
when 평균 단가<20000 then price*0.0' at line 3
select restaurant_name,
평균 단가,
case when 평균 단가<5000 then price*0.005
when 평균 단가<20000 then price*0.01
when 평균 단가<30000 then price*0.02
else price*0.03 end '수수료'
from
(
SELECT restaurant_name, avg(price/quantity) '평균 단가'
from food_orders
group by 1
) a
오류 발생 시, 작성한 코드 전체와 에러 메시지를 첨부해 주세요.
Tip 1) </> 아이콘을 눌러 코드박스를 만들어 보세요.
Tip 2) Ctrl+A(맥의 경우 Command+A) 단축키로 코드를 한 번에 선택할 수 있어요!
