📌 문제
https://solvesql.com/problems/installment-month/
📌 정답
select payment_installments,
count(distinct order_id) as order_count,
min(payment_value) as min_value,
max(payment_value) as max_value,
avg(payment_value) as avg_value
from olist_order_payments_dataset
where payment_type like 'credit_card'
group by payment_installments
💡포인트
- 주문 데이터는 보통 각 주문 항목 별 하나의 행으로 구성된다. 따라서, 한 주문에 대해서 여러 물건을 구매한 경우 주문번호 중복이 발생하므로 중복을 제거해야 한다.
- 신용카드로 결제한 내역이므로 payment_type 조건이 있어야 한다.
💡 질문과 피드백 사항은 댓글에 편하게 남겨주시기 바랍니다.
❤️ 도움이 되셨다면 공감 부탁드립니다.