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

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

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

with t1 as (
select (select date(max(event_time)) from tb_order_overall tl) as current_t,
date(event_time) as event_time,
ti.product_id,
td.order_id,
uid
from tb_product_info ti
left join tb_order_detail td on ti.product_id = td.product_id
left join tb_order_overall tl on td.order_id = tl.order_id
where tag='零食'
and status = 1
)
select product_id,
round(count(distinct case when num>=2 then uid else null end )/count(distinct uid),3) as repurchase_rate
from(
select product_id,
uid,
count(order_id) as num
from t1
where datediff(current_t,event_time)<90
group by product_id,
uid
)a 
group by  product_id
order by repurchase_rate desc , product_id
limit 3



全部评论

相关推荐

不愿透露姓名的神秘牛友
01-09 15:20
腾讯给员工发甘蔗,乍一看是要去攻打字节吗?
天秤slam:排队等着挨削
投递字节跳动等公司10个岗位 >
点赞 评论 收藏
分享
2024-11-19 15:16
武汉理工大学 Java
喀什克尔的胡杨:秋招面了很多主管,感觉主管都是傻蛋
点赞 评论 收藏
分享
2024-11-30 22:57
门头沟学院 golang
牛客533433175号:更可气的是我做完这些给我拒了
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务