题解 | #牛客的课程订单分析(五)#
牛客的课程订单分析(五)
https://www.nowcoder.com/practice/348afda488554ceb922efd2f3effc427
with t as(
select user_id
,date
,row_number()over(partition by user_id order by date)rk
,count(product_name)over(partition by user_id) cnt
from order_info
where product_name in ("Python","Java","C++")
and date>"2025-10-15"
and status="completed"
)
select t1.user_id
,t1.date
,t2.date
,t1.cnt
from t t1
left join t t2
on t1.user_id=t2.user_id and t1.rk+1=t2.rk
where t1.cnt>1 and t1.rk=1