题解 | 牛客的课程订单分析(五)
牛客的课程订单分析(五)
https://www.nowcoder.com/practice/348afda488554ceb922efd2f3effc427
select
user_id,first_buy_date,second_buy_date,cnt
from
(select
user_id,
min(date) over(partition by user_id) as first_buy_date,
lead(date,1,0) over(partition by user_id order by date) as second_buy_date,
count(*) over(partition by user_id) as cnt,
date
from order_info
where date>='2025-10-16'
and status='completed'
and product_name in('C++','Java','Python')
) a
where a.cnt>=2 and date=first_buy_date
order by a.user_id ;
查看11道真题和解析