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

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

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

select product_id,
round(sum(repurchase)/count(uid),3) as repurchase_rate
from(
select uid,product_id,if(count(event_time)>1,1,0) as repurchase
from tb_order_detail as t1
inner join tb_order_overall as t2 using(order_id)
inner join tb_product_info as t3 using(product_id)
where tag='零食'
and event_time>=(select date_sub(max(event_time),interval 89 day)
from tb_order_overall)
group by uid,product_id)
as t1
group by product_id
order by repurchase_rate desc,product_id
limit 0,3

全部评论

相关推荐

不愿透露姓名的神秘牛友
01-20 15:00
点赞 评论 收藏
分享
马国成同志:如果是真大专的话 可以直接进厂 没必要搞简历 太正式了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务