1、窗口函数计数
select id,client_id,is_group_buy, count(status) over (partition by user_id) as cnt from order_info where date>'2025-10-15' and status='completed' and product_name in ('C++','Java','Python')2、左连接left join , case when 条件填充
select a.id, a.is_group_buy, case when a.is_group_buy='No' then b.name else NULL end as client_name from (select id,client_id,is_group_buy, count(status) over (partition by user_id) as cnt from order_info where date>'2025-10-15' and status='completed' and product_name in ('C++','Java','Python')) as a left join client as b on a.client_id=b.id where a.cnt>=2 order by id;