1、统计每个客户端的订单数量(注0为拼团成功,不显示客户端,需对客户端去重)和每个用户的下单数量
select distinct client_id,is_group_buy,
count(status) over(partition by client_id) as cnt_client_id,
count(status) over (partition by user_id) as cnt_user_id
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
2、1表与client表做连接,case when 条件修改None 为GroupBuy
select case when a.is_group_buy = 'Yes' then 'GroupBuy' else b.name end source,
a.cnt_client_id as cnt
from
(select  distinct client_id,is_group_buy,
count(status) over(partition by client_id) as cnt_client_id,
count(status) over (partition by user_id) as cnt_user_id
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 cnt_user_id>=2
order by source ;