본문 바로가기

SQL 데이터베이스/Mysql

MySQL 13강

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

'SQL 데이터베이스 > Mysql' 카테고리의 다른 글

MySQL 14강  (0) 2021.12.04
MySQL 12강  (0) 2021.12.03
MySQL 11-2강  (0) 2021.12.03
MySQL 11강  (0) 2021.12.03
MySQL 10-2강  (0) 2021.12.03