题解 | 牛客的课程订单分析(六)
牛客的课程订单分析(六)
https://www.nowcoder.com/practice/c5736983c322483e9f269dd23bdf2f6f
select sub.id,sub.is_group_buy,
case when sub.is_group_buy='No' then c.name else NULL end as client_name
from(select id,client_id,is_group_buy,count(*)over(partition by user_id) as cnt
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.cnt>=2
order by sub.id
注意:
1、表的链接方式:保证筛选后的order_info全在,用left join
2、输出空值,不用‘NULL’,直接null即可
查看10道真题和解析