题解 | #牛客的课程订单分析(五)#
牛客的课程订单分析(五)
https://www.nowcoder.com/practice/348afda488554ceb922efd2f3effc427
select * from( select distinct user_id, min(`date`)over(partition by user_id) as first_buy_date, if(dense_rank()over(partition by user_id order by date asc) = 2,`date`,null) as second_buy_date, count(*)over(partition by user_id) as cnt from order_info where `date` > '2025-10-15' and product_name in ('C++','Java','Python') and status = 'completed' ) as t1 where t1.second_buy_date is not null;