题解 | #牛客的课程订单分析(七)#空值填充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(字段名,要填充的内容)
爱玛科技公司福利 6人发布