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

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

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

with a2 as(
with a1 as(
select t1.product_id,uid
from
tb_order_detail t1
left join
tb_order_overall t2
on t1.order_id = t2.order_id
left join 
tb_product_info t3
on t1.product_id = t3.product_id
where datediff( (select max(date(event_time))
from
tb_order_overall),event_time) <= 89
and tag = '零食')
select product_id,uid,count(*) each_cnt
from a1
group by product_id,uid)
select product_id,round(sum(if(each_cnt >=2,1,0))/count(distinct uid),3) repurchase_rate
from a2
group by product_id
order by repurchase_rate desc,product_id
limit 3;

全部评论

相关推荐

点赞 评论 收藏
分享
Lorn的意义:你这种岗位在中国现在要么牛马天天加班,要么关系户进去好吃好喝,8年时间,真的天翻地覆了,对于资本来说你就说一头体力更好的牛马,哎,退伍没有包分配你真的亏了。
点赞 评论 收藏
分享
06-20 16:12
门头沟学院 Java
rakkaus:助学金,,,这个就不用写吧
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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