思路:①根据非聚合类的筛选条件建表tb1(如2025-10-15以后、购买课程为JAVA/C++、必须完成购买为非聚合筛选);
②基于tb1,根据聚合筛选条件(成功购买2次以上)筛出user_id形成tb2;
③将tb2左连接tb1即可。
with tb1 as (
select * from order_info
where date>'2025-10-15' and status='completed' and product_name in ('C++','Java','Python'))

select id, user_id, product_name, status, client_id, date from 
(select user_id from tb1 group by user_id having count(user_id)>=2) as tb2
left join tb1 using(user_id)
order by id