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