select d.user_id as id,d.date as d1,c.date as d2,d.count as count from ( select a.user_id as user_id,min(b.date) as date,a.count from ( select user_id,min(date)as date,count(user_id)as count from order_info where product_name in ('C++','Python','Java') and status='completed' and date>'2025-10-15' group by(user_id) having count('user_id')>=2 order by user_id )as a left join order_info as b on a.user_id=b.user_id where b.date>a.date and b.date>'2025-10-15' and b.status='completed' group by a.user_id order by b.date asc )as c left join ( select user_id,min(date)as date,count(user_id)as count from order_info where product_name in ('C++','Python','Java') and status='completed' and date>'2025-10-15' group by(user_id) having count('user_id')>=2 order by user_id )as d on c.user_id=d.user_id order by d.user_id asc 只要有思路就能写出来。