SQLite/solvesql 할부는 몇 개월로 해드릴까요

[SQLite/solvesql] 할부는 몇 개월로 해드릴까요

📌문제링크

고전적인 groupby 문제다.
할부개월별 주문 count를 체크할때 order_id의 중복여부를 체크하자


solution

1
2
3
4
5
6
7
8
9
10
11
12
13
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 = 'credit_card'
group by
  payment_installments