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

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

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

-- 1 算零食类商品的各个商品的复购率 2 order by ,limit 3
with tt as(
    select d.product_id, event_time, uid from tb_order_detail d left join tb_order_overall o using(order_id) left join tb_product_info i using(product_id)
    where tag ='零食'
)
-- 求复购的人数目
, tb as(
    select * from tt where event_time >= (select date_sub(max(event_time), interval 89 day) from tb_order_overall)
)
select 
    product_id, 
    round( (count(uid) - count(distinct uid))/count(distinct uid), 3) g
    from tb
    group by 1

    order by 2 desc, 1 asc
    limit 3


题目描述的一团浆糊,垃圾题目,尤其是90天以内的那什么玩意。知识点考的还好。

全部评论
包含当天,比如今天是12.22那么一天内就减0就可以了,同理,90天内包含当天是减89
点赞 回复 分享
发布于 2024-12-22 12:02 广东

相关推荐

点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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