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

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

https://www.nowcoder.com/practice/c93d2079282f4943a3771ca6fd081c23

# 先找到满足要求的用户id
with t1 as (
    select user_id, count(id) as cnt
    from order_info
    where date >= '2025-10-15'
    and status = 'completed'
    and product_name in ("C++", "Java", "Python")
    group by user_id
    having cnt >= 2
)# 找到没开始的一次购买日期
select t1.user_id, a.first_buy_date, t1.cnt
from t1
left join (
    select user_id, min(date) as first_buy_date
    from order_info
    where user_id in (select user_id from t1)
    and date >= '2025-10-15'
    and status = 'completed'
    and product_name in ("C++", "Java", "Python")
    group by user_id
) as a
on t1.user_id = a.user_id
order by t1.user_id;


全部评论

相关推荐

在打卡的大老虎很想潜...:你在找实习,没啥实习经历,技术栈放前面,项目多就分两页写,太紧凑了,项目你最多写两个,讲清楚就行,项目背景。用到的技术栈、亮点、难点如何解决,人工智能进面太难了,需求少。你可以加最新大模型的东西
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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