题解 | #牛客的课程订单分析(五)#

牛客的课程订单分析(五)

https://www.nowcoder.com/practice/348afda488554ceb922efd2f3effc427

select t3.user_id,t3.first_buy_date,t4.second_buy_date,t3.cnt
from(
		select user_id,`date` first_buy_date,cnt
		from(
				select user_id,`date`,product_name,
				dense_rank() over(partition by user_id order by `date`) rk,
				count(1) over(partition by user_id) cnt
				from order_info
				where date > '2025-10-15'
				and product_name in ('C++','Java','Python')
				and status = 'completed'
		) t1
		where cnt >= 2
		and rk = 1
) t3 join (
	select user_id,`date` second_buy_date,cnt
	from(
			select user_id,`date`,product_name,
			dense_rank() over(partition by user_id order by `date`) rk,
			count(1) over(partition by user_id) cnt
			from order_info
			where date > '2025-10-15'
			and product_name in ('C++','Java','Python')
			and status = 'completed'
	) t2
	where cnt >= 2
	and rk = 2
) t4 on t3.user_id = t4.user_id
order by user_id;

全部评论

相关推荐

牛客410815733号:这是什么电影查看图片
点赞 评论 收藏
分享
扭转乾坤_:现在企业都是学华为,一直通过丢池子里,最后捞
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务