with
t1 as(
select
user_id,
date,
dense_rank()over(partition by user_id order by date) as date_rank,
count(user_id)over(partition by user_id) as course_count
from
order_info
where
status='completed'
and
product_name in ('C++','Java','Python')
and
date>'2025-10-15'
)
select
distinct user_id,
date as first_buy_date,
course_count as cnt
from
t1
where
date_rank=1
and
course_count>=2
order by
user_id

京公网安备 11010502036488号