题解 | #牛客的课程订单分析(七)#
https://www.nowcoder.com/practice/d6f4a37f966145da8900ba9edcc4c068
select case when a.client_id='0' then 'GroupBuy' else b.name end source,count(*) cnt
from order_info a left join client b
on a.client_id=b.id
where date>'2025-10-15'
and status ="completed"
and product_name in("C++","Java","Python")
and a.user_id in
(select user_id
from order_info
where date>'2025-10-15'
and status ="completed"
and product_name in("C++","Java","Python")
group by user_id
having count(id)>=2)
group by source
from order_info a left join client b
on a.client_id=b.id
where date>'2025-10-15'
and status ="completed"
and product_name in("C++","Java","Python")
and a.user_id in
(select user_id
from order_info
where date>'2025-10-15'
and status ="completed"
and product_name in("C++","Java","Python")
group by user_id
having count(id)>=2)
group by source
order by source
要求不高,能过就行。