https://solvesql.com/problems/installment-month/
🔍 문제
할부 개월 수 별로 최대 결제 금액, 최소 결제 금액, 결제 횟수, 평균 결제 금액을 구하면 되는 문제다.
중요한건!!!
- 신용 카드로 결제한 건수!
- 고유한 주문 건수만 봐야 한다는 것!
이 두 가지 사항만 잘 확인하면 쉽게 풀 수 있었다.
🎯정답
select
distinct(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 = 'credit_card'
group by payment_installments;
❓풀이
- `payment_type`에 "credit_card"를 적용하지 않아서 계속 애먹었다. 문제 꼭 잘 읽기
'프로그래밍 언어 > 02. SQL' 카테고리의 다른 글
| [PostgreSQL] solvesql LV.3 쇼핑몰의 일일 매출액과 ARPPU (0) | 2025.10.12 |
|---|---|
| [PostgreSQL] solvesql LV.3 배송 예정일 예측 성공과 실패 (0) | 2025.10.11 |
| [PostgreSQL] solvesql LV.2 3년간 들어온 소장품 집계하기 (0) | 2025.10.09 |
| [PostgreSQL] solvesql LV.2 언더스코어(_)가 포함되지 않은 데이터 찾기 (0) | 2025.10.07 |
| [PostgreSQL] solvesql LV.2 다음날도 서울숲의 미세먼지 농도는 나쁨 (0) | 2025.10.07 |
