select case a.client_id
when '0' then 'GroupBuy'
else b.name end as source
,count(a.client_id) as cnt
from (
select user_id, client_id, count(id) over(partition by user_id) as buy_cnt
from order_info
where product_name in ('C++', 'Java', 'Python')
and date > '2025-10-15'
and status = 'completed'
) a left join client b on a.client_id = b.id
where a.buy_cnt >= 2
group by source
order by source 
京公网安备 11010502036488号