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

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

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

with t1 as (
    select id, user_id, client_id, is_group_buy
    from order_info
    where date >= '2025-10-15'
    and status = 'completed'
    and product_name in ("C++", "Java", "Python")
),
t2 as (
    select * 
    from t1
    where user_id in (
        select user_id
        from t1
        group by user_id
        having count(id) >= 2
    )
)
select *
from (
    (select "GroupBuy" as source, count(id) as cnt
    from t2
    where is_group_buy = "Yes")
    union all
    (select a.name as source, count(t2.id) as cnt
    from t2
    left join client as a
    on a.id = t2.client_id
    where t2.is_group_buy = "No"
    group by a.name)
) as b
order by source;


全部评论

相关推荐

大佬们,在大厂实习的都是几百一天???
爱睡觉的冰箱哥:实习工资这个不都是公开的吗,a不了,字节400,快手350,有些有房补餐补这样
点赞 评论 收藏
分享
真烦好烦真烦:牛友太有实力了
点赞 评论 收藏
分享
05-26 16:13
门头沟学院 C++
牢大肘击Java:海投就完事了bro,就当刷视频了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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