anonymous02 2021. 12. 4. 22:36

select avg(days_since_prior_order) from instacart.orders where order_number = 2;
13.6518


select count(product_id) / count(distinct order_id) UPT from instacart.order_products__prior;
10.0467


select count(distinct order_id) / count(distinct user_id) AF from instacart.orders;
1.0193



select product_id, sum(reordered) / count(*) from instacart.order_products__prior group by 1;
40174	0.5882
17461	0.7059
19731	0.6000
24838	0.6429
24852	0.8189



select *, row_number() over(order by RET DESC) RNK 
from (select product_id, sum(reordered) / count(*) RET from instacart.order_products__prior group by 1)A limit 5;
6011	1.0000	1
34817	1.0000	2
23565	1.0000	3
44233	1.0000	4
24668	1.0000	5