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

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

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

全部评论

相关推荐

牛客583549203号:腾讯还好,况且实习而已,实习生流动性很大,属于正常现象,记得和HR委婉解释
点赞 评论 收藏
分享
04-16 19:19
已编辑
合肥大学 Java
刷了100道题的大老虎很想提桶:27届现在早没日常hc了,不可能找到的,等暑假9月吧
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务