题解 | #零食类商品中复购率top3高的商品#

零食类商品中复购率top3高的商品

https://www.nowcoder.com/practice/9c175775e7ad4d9da41602d588c5caf3

select

product_id,

round(sum(comt)/count(distinct uid),3) repurchase_rate

from

(

select

product_id,

uid,

if(com>1,1,0) comt

from

(

select

product_id,

uid,

count(*) com

from

(select

a.product_id,

uid

from

tb_product_info a,

tb_order_overall b,

tb_order_detail c

where

a.product_id=c.product_id and b.order_id = c.order_id

and tag = '零食'

and datediff((select max(date(event_time)) from tb_order_overall),date(event_time)) <=89

order by product_id,uid

) t1

group by product_id,uid

order by product_id

) t2

) t3

group by product_id

order by repurchase_rate desc

limit 3;

全部评论

相关推荐

明天不下雨了:这个项目 这个简历 这个模板 莫不是一个开源的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务