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

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

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

with t1 as (
select *
from tb_order_overall
    where datediff((select max(date(event_time)) max_date
from tb_order_overall), date(event_time)) <= 89)

select product_id, round(sum(if((purchase_time >=2), 1, 0)) / unum, 3) repurchase_rate
from
(select product_id, t3.uid, count(1) purchase_time
from tb_order_detail t2
left join t1 t3 using(order_id)
group by product_id, t3.uid) t7
left join
(select product_id, count(distinct t5.uid) unum
from tb_order_detail t4
left join t1 t5 using(order_id)
group by product_id) t6 using(product_id)
left join tb_product_info ti using(product_id)
where ti.tag = '零食'
group by product_id
order by repurchase_rate desc ,product_id
limit 3

注意几个条件:

  1. 90天之内,包括当天,所以和最大日期的date_diff应该小于等于89天
  2. 注意tag标签是零食类的
  3. 只取top3 所以最终结果要limit 3
全部评论

相关推荐

07-15 16:52
已编辑
门头沟学院 Java
周五投的,流程今天结束
投递地平线等公司7个岗位
点赞 评论 收藏
分享
zzzzhz:兄弟你先猛猛投简历至少三百家,能约到面试就去面。最近可以速成智能小车,智慧家居烂大街的项目,不需要自己写,只需要把里面的代码讲解看明白就行。把其中涉及到的八股文都拿出来单独背一下,我去年找工作就一个智能小车智慧家居找了10k差不多。
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-10 14:10
啊啊啊啊好幸福,妈妈是我找工作发疯前的一束光
黑皮白袜臭脚体育生:看了这篇帖子之后已经第一百次质问老妈,仍然没有得到我的老妈是老板的回答
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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