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

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

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

select product_id,
			 round(count(if(repurchase_cnt>1,uid,null))/count(uid),3) as repurchase_rate
from (
	select product_id,uid,
				 count(if(datediff(max_date,date(event_time))<=89,1,null)) as repurchase_cnt
	from tb_product_info
	left join tb_order_detail using(product_id)
	left join tb_order_overall using(order_id)
	left join (select max(date(event_time)) as max_date
						 from tb_order_overall) as t on 1
	where tag='零食'
	group by product_id,uid
	  ) as a
group by product_id
order by repurchase_rate desc,product_id
limit 3
全部评论

相关推荐

12-03 23:38
复旦大学 Java
点赞 评论 收藏
分享
哇哇的菜鸡oc:他这不叫校招offer,而是实习offer
点赞 评论 收藏
分享
11-04 19:05
已编辑
东莞城市学院 单片机
不知道怎么取名字_:你这个要实习两年?哪有这么久的,感觉就是即使你毕业了,但还按实习的话,是不是不用给你缴社保公积金啥的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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