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

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

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

/*
    select
                user_id
                ,case when t1.is_group_buy = 'NO' then t2.name else 'GroupBuy' end as     `source`
                ,count(*) over (partition by t1.user_id) as 'num'
    from
                    order_info  t1
        left join   client  t2  on t1.client_id = t2.id and t1.product_name in ('C++','Python','Java')
        and t1.date >= '2025-10-15' and t1.status = 'completed'
*/
select distinct
*
from
(
select
        case when is_group_buy = 'No' then t2.name else 'GroupBuy' end  as   `source`
        ,count(*) over (partition by t1.client_id) as   `cnt`
from
    order_info t1
    left join   client t2  on t1.client_id = t2.id
where
        t1.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(*)>=2
        ) and   t1.date >= '2025-10-15' and t1.status = 'completed' and t1.product_name in ('C++','Python','Java')
) t4        
order by t4.source

全部评论

相关推荐

04-21 11:22
已编辑
中华女子学院 UE4
耐心学习_佩可officical:直接举报他,佬,违反劳动法我记得boss会下架
点赞 评论 收藏
分享
04-11 21:31
四川大学 Java
野猪不是猪🐗:(ja)va学弟这招太狠了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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