思路:由于要取出所有订单,所以用窗口函数,case when+group by 得到新列
select
case when client_name is null then 'GroupBuy' else client_name end source
,count() cnt
from
(
select
o.id
,name client_name
,count(
)over(partition by user_id) cnt_a
from order_info o
left join client c on o.client_id = c.id
where date > '2025-10-15'
and status = 'completed'
and product_name in ('C++','Java','Python')
) a
where cnt_a>=2
group by 1
order by 1