with first as (
select user_id,min(date) first_date,count(*) cnt
from order_info
where date>='2025-10-15'
and status='completed'
and product_name in ('C++','Java','Python')
group by user_id
having count(*)>=2
),
second as (
SELECT user_id,date second_date
from (
select *
,row_number()over(partition by user_id order by date) posn
from order_info
where date>='2025-10-15'
and status='completed'
and product_name in ('C++','Java','Python')
) as t
where posn=2
)
SELECT first.user_id,first.first_date,second.second_date,first.cnt
from first
inner join second
on first.user_id=second.user_id
order by first.user_id