with t as( select distinct user_id, count(id) over(partition by user_id) cnt from order_info where date>'2025-10-15' and status='completed' ), t1 as( select o.id id, ifnull(c.name,'GroupBuy') source from order_info o left join client c on o.client_id=c.id left join t on o.user_id=t.user_id where date>'2025-10-15' and status='completed' and cnt>=2 and product_name in ('C++','Python','Java') order by o.id ) select distinct source, count(id) over(partition by source) cnt from t1
空值填充:ifnull(字段名,要填充的内容)