select *
from (
select A.user_id,min(o.date) first_buy_date,A.nn cnt
from order_info o
left join(
select user_id,count(user_id) nn from order_info
where date > '2025-10-15' and
status = 'completed' and product_name in('C++','Python','Java')
group by user_id
having count(user_id)>1
order by user_id
) A on o.user_id = A.user_id
where o.date > '2025-10-15' and
o.status = 'completed' and o.product_name in('C++','Python','Java')
group by A.user_id
order by A.user_id) B
where B.user_id is not null;