第一种:使用开窗函数 select r.client_name as source, count(r.id) from( select t.id, t.is_group_buy, (case when t.is_group_buy="No" then c.name else 'GroupBuy' end) as client_name from ( select *, count(*) over(partition by user_id) as cnt_course from order_info ...