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