题解 | #牛客的课程订单分析(七)#

牛客的课程订单分析(七)

https://www.nowcoder.com/practice/d6f4a37f966145da8900ba9edcc4c068


select coalesce(name,'GroupBuy') as source,count(1) as cnt 
from 
(    select *
    ,count(1)over(partition by user_id) as ct 
    from order_info
    where date >'2025-10-15'
    and status='completed'
    and product_name in ('C++','Java','Python')
) a left join client on a.client_id=client.id
where ct>=2
group by name
order by source

和上一题的写法差不多,这里直接group by name,就ok了,null会自动分为一组,使用coalesce(a,b,c,.......)来修改别名,

coalesce(name,'GroupBuy') 这里的意思是name列如果有null值,则返回GroupBuy

全部评论

相关推荐

后来123321:别着急,我学院本大二,投了1100份,两个面试,其中一个还是我去线下招聘会投的简历,有时候这东西也得看运气
点赞 评论 收藏
分享
03-27 20:14
前端工程师
投票
Spring启动:我在一嗨呆过,这么说吧 神仙单位,除了工资不怎么好 剩下的基本上天花板了,上班下班跟公务员似的,一天工作7个点,提供宿舍,宿舍离公司1km, 项目不着急,一般来说1天的活,你要个4天没人管你,我一天上班4个点在微信上跟别人聊天😂 去那边老自在了 但是也有可能是 我们组比较好
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务