
1. 상품 준비시간이 20~30분 사이인, 한국음식점의 식당명과 고객번호 조회하기
SELECT order_id, restaurant_name
FROM food_orders
where food_preparation_time between 20 and 30
AND cuisine_type = 'korean'
2. 음식 종류별 가장 높은 주문 금액과 가장 낮은 주문금액을 조회하고, 가장 낮은 주문금액 순으로 (내림차순) 정렬하기
SELECT fo.cuisine_type, #음식 종류 불러오기
min(fo.price) as min_price, #낮은 주문금액
max(fo.price) as max_price #높은 주문금액
from food_orders fo #food_orders를 fo로 정의
GROUP BY fo.cuisine_type
ORDER BY min_price DESC
3. 다음의 조건으로 배달시간이 늦었는지 판단하는 값을 만들어주세요.
주중 : 25분 이상
주말 : 30분 이상
SELECT case when fo.day_of_the_week='weekday' then if(delivery_time>25, 'Late', 'On-time')
when fo.day_of_the_week='weekend' then if(delivery_time>30, 'Late', 'On-time')
end as "지연여부",
fo.order_id as "고객 ID",
fo.restaurant_name as "음식점 이름",
fo.day_of_the_week as "배달요일",
fo.delivery_time as "배달시간"
from food_orders fo #food_orders를 fo로 정의
ORDER BY fo.day_of_the_week, fo.delivery_time