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

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

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;


全部评论

相关推荐

frutiger:逆天,我家就安阳的,这hr咋能说3k的,你送外卖不比这工资高得多?还说大厂来的6k,打发叫花子的呢?这hr是怎么做到说昧良心的话的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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