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

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

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

select
    user_id,
    first_buy_date,
    second_buy_date,
    cnt
from
    (
    select
        *,
        min(date) over(partition by user_id ) first_buy_date,
        lead(date,1) over(partition by user_id order by date) second_buy_date,
        count(product_name) over(partition by user_id) cnt,
        row_number() over(partition by user_id order by date) rn
    from 
        order_info 
    where 
        status = 'completed' 
        and 
        product_name in ('Python','Java','C++')
        and 
        date>'2025-10-15'
        ) t1
where cnt>=2 and rn = 1
order by user_id

全部评论

相关推荐

10-17 23:18
已编辑
西北农林科技大学 Web前端
独行m:给25可以试试,但他只能给12,那就是纯纯的事精
秋招,不懂就问
点赞 评论 收藏
分享
顺利毕业的鸽子:这个不一定,找hr跟进一下
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务