select 
 (case when d.is_group_buy ='No' 
 then c.name 
 else 'GroupBuy' end) as source,
   count(*) as cnt

   from
    (select b.is_group_buy,b.client_id from
(select user_id,id,client_id,is_group_buy,
count(*) over(partition by user_id ) as num

    from order_info 
    where date>'2025-10-15'
    and status ='completed'
    and (product_name ='C++' or product_name ='Java' or product_name ='Python')
    )b
    where b.num>=2)d

    left join client c 
    on d.client_id = c.id
group by (case when d.is_group_buy ='No' then c.name 
    else 'GroupBuy' end)
    order by source

要细心