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

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

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

方法一:窗口函数
select a.id,a.user_id,a.product_name,a.status,a.client_id,a.date from 
(select *,
case when (count(user_id)over(partition by user_id))>1 then 1
else 0 end ct from order_info where date >'2025-10-15' and status='completed' and product_name in ('C++','Python','Java')) a
where a.ct=1
order by a.id

方法二:常规聚合
select * from order_info where user_id in 
(select user_id from order_info where date >'2025-10-15' and status='completed' and product_name in ('C++','Python','Java')
group by user_id having count(user_id)>1)
and date >'2025-10-15' and status='completed' and product_name in ('C++','Python','Java')
order by id


全部评论

相关推荐

11-03 13:18
门头沟学院 Java
包行:平时怎么刷算法题的哇,字节的手撕听说都很难
字节跳动工作体验
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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