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

相关推荐

牛客96763241...:杭电✌️也是打完招呼,没人回吗
点赞 评论 收藏
分享
10-10 01:10
已编辑
深圳大学 测试开发
面了100年面试不知...:六月到九月,四个项目一个实习,是魔丸吗
投了多少份简历才上岸
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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