题解 | #牛客的课程订单分析(七)#空值填充ifnull

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

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


with t as(
    select distinct user_id,
        count(id) over(partition by user_id) cnt
    from order_info
    where date>'2025-10-15'
    and status='completed'
),

t1 as(
    select o.id id,
        ifnull(c.name,'GroupBuy') source
    from order_info o
    left join client c on o.client_id=c.id
    left join t on o.user_id=t.user_id
    where date>'2025-10-15'
    and status='completed'
    and cnt>=2
    and product_name in ('C++','Python','Java')
    order by o.id
)

select 
    distinct source,
    count(id) over(partition by source) cnt
from t1


空值填充:ifnull(字段名,要填充的内容)

全部评论

相关推荐

05-29 09:02
门头沟学院 Java
点赞 评论 收藏
分享
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-10 11:27
明天又是董事长面,啥时候是个头啊
积极向上的林同学:董事长亲自面试
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务