题解 | #牛客的课程订单分析(七)#
牛客的课程订单分析(七)
http://www.nowcoder.com/practice/d6f4a37f966145da8900ba9edcc4c068
按照source聚合时需要用case when 判断条件
```select case when a.is_group_buy = 'No'then c.name else 'GroupBuy' end as source
,count(product_name) as scnt
from (
select *
,count(*) over(partition by user_id) as cnt
from order_info
where date > '2025-10-15'
and status = 'completed'
and product_name in ('C++','Python ','Java')
)a
left join client c on a.client_id = c.id
where a.cnt >=2
group by 1
order by 1