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

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

https://www.nowcoder.com/practice/4ae8cff2505f4d7cb68fb0ec7cf80c57

一旦学会窗口函数,突然有种sql刷起来很无趣的感觉

select id, user_id, product_name, status, client_id, date from 
(
select id, user_id, product_name, status, client_id,date,
sum(case when status ='completed' then 1 else 0 end)  over (partition by user_id) as completed_cnt
from order_info where date > '2025-10-15' and product_name in ('C++','Java','Python') and status = 'completed'
) t where t.completed_cnt >= 2 order by id asc



全部评论

相关推荐

搞机墨镜猫:对了,现在拿offer都是顶天星战神,我们普通人还是老老实实准备后面的秋招
点赞 评论 收藏
分享
小憨包沈幼楚:沈幼楚是支持学习的第一动力
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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