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

select user_id,
    min(date) as first_buy_date,
    min(next_date) as second_buy_date,
    max(number) as cnt
from (
    select *,
        row_number() over(partition by user_id order by date) as number,
        lead(date,1) over(partition by user_id order by date) as next_date
    from order_info
    where date>'2025-10-15'
    and status='completed'
    and product_name in ('Python','Java','C++')
    order by user_id) as t
group by user_id
having count(*)>=2
order by user_id;

全部评论

相关推荐

贺兰星辰:不要漏个人信息,除了简历模板不太好以外你这个个人简介是不是太夸大了...
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务