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



全部评论

相关推荐

点赞 评论 收藏
分享
11-13 11:12
门头沟学院 Java
咩咩子_:专业技能写上面 项目往下放,如果可以的话改一下学校最好
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务