with t as
(select * from order_info where date>'2025-10-15' and status='completed' and product_name in ('Python','Java','C++'))
select t1.user_id,min(t1.date) first_buy_date,min_date
second_buy_date,count(*) cnt from t t1
join (select user_id,min(date) min_date from t where (user_id,date) not in (select user_id,min(date) from t group by user_id)
group by user_id ) t2
on t1.user_id=t2.user_id
group by t1.user_id order by t1.user_id;