题解 | #牛客的课程订单分析(四)#
牛客的课程订单分析(四)
https://www.nowcoder.com/practice/c93d2079282f4943a3771ca6fd081c23
select distinct user_id, first_buy_date, cnt
from
(
select *,
min(date)over(partition by user_id) first_buy_date,
count(user_id)over(partition by user_id) cnt
from order_info
where
date >= '2025-10-15'
and status = 'completed'
and product_name in ('C++','Java','Python')
) b
where cnt >=2
order by user_id
#窗口函数的计算结果进行筛选,需要使用子查询,不能用where或having
凡岛公司福利 528人发布