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

SELECT b1.user_id, b1.first_buy_date, b1.second_buy_date, b1.cnt
FROM (
    SElECT user_id, product_name, date,
MIN(date) OVER (PARTITION BY user_id) AS first_buy_date,
LEAD(date) OVER (PARTITION BY user_id ORDER BY date) AS second_buy_date,
COUNT(*) OVER (PARTITION BY user_id) AS cnt
FROM order_info
WHERE date>='2025-10-15' AND status='completed'
AND product_name IN ('C++','Python','JAVA')) AS b1
WHERE b1.date=b1.first_buy_date
AND b1.second_buy_date IS NOT NULL

全部评论

相关推荐

点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务