
강사님의 쓰신 코드 예제는
select cuisine_type,
sum(price) price,
sum(price*discount_rate) discounted_price
from
(select f.cuisine_type,
f.price,
c.age,
(c.age-50)*0.005 discount_rate
from food_orders f left join customers c on f.customer_id=c.customer_id
where c.age>=50
) a
group by 1
order by 3 desc
근데 제가 서브 쿼리문 작성해야하는 걸 모르고
select f.cuisine_type,
sum(f.price) price,
sum(f.price*((c.age-50)*0.005)) discounted_price
from food_orders f left join customers c on f.customer_id=c.customer_id
where c.age>=50
group by 1
order by 3 desc
이렇게 써버렸어요.
궁금한 게 위아래 결과값이 같은게 맞나요? 강사님이랑 저랑 결과가 달라서 여쭤봅니다.
