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


京公网安备 11010502036488号