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

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

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

/*
1.2025-10-15以后,同一个用户下单2个以及2个and status=completed and product_name in(C++,Python,Java)
2.符合1的客户端,
3.2得出的客户端对应的总订单
*/


# order_info 肯定是要和client连接,并且cliend_id=0的要将他改成GroupBuyf


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

ifnull(字段,‘default value’) 可以直接修改字段里面的值

全部评论

相关推荐

熊大不大:微信也是华为旗下吧,我看我朋友也是华为工牌写wx
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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