문제
SQLite
내가 작성한 오답
:결제 고객 1인 당 평균 결제 금액을 구해야했으므로 avg로 평균값을 구하면 안됐다.
select date(o.order_purchase_timestamp) dt,
count(distinct o.customer_id) pu,
round(sum(p.payment_value),2) revenue_daily,
round(avg(p.payment_value),2) arppu
from olist_orders_dataset o
join olist_order_payments_dataset p
on o.order_id = p.order_id
where date(o.order_purchase_timestamp) >= '2018-01-01'
group by dt
order by 1
내가 작성한 정답
select date(o.order_purchase_timestamp) dt,
count(distinct o.customer_id) pu,
round(sum(p.payment_value),2) revenue_daily,
round(sum(p.payment_value)/count(distinct o.customer_id),2) arppu
from olist_orders_dataset o
join olist_order_payments_dataset p
on o.order_id = p.order_id
where date(o.order_purchase_timestamp) >= '2018-01-01'
group by dt
order by 1
Share article