题解 | #零食类商品中复购率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;

全部评论

相关推荐

06-11 15:52
东南大学 C++
问了一下hr,这个回答是G了吗
椛鸣:我遇到过 我给你翻一下 对不起 我之前把你当备胎了 现在我人已经招满了 ***吧
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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