题解 | 牛客的课程订单分析(七)
牛客的课程订单分析(七)
https://www.nowcoder.com/practice/d6f4a37f966145da8900ba9edcc4c068
select case when c.name is not null then c.name else 'GroupBuy' end as source,
count(*) as cnt
from(select id,client_id,is_group_buy,count(*)over(partition by user_id) as rn
from order_info
where status='completed' and date>'2025-10-15'
and product_name in('C++','Java','Python'))sub
left join client c on sub.client_id=c.id
where sub.rn>=2
group by c.name
order by source
错误:case when sub.is_group_buy='No' then c.name else NULL end as client_name
借用这个表达,这样group by中无法组合


查看23道真题和解析