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

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

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

select
    oi.id,
    is_group_buy,
    if(is_group_buy = 'NO',name, 'None') as client_name
from
    order_info oi
    left join client c on oi.client_id = c.id
where
    date > '2025-10-15'
    and status = 'completed'
    and product_name in ('C++', 'Java', 'Python')
    and user_id in (
        select
            user_id
        from
            order_info
        where
            date > '2025-10-15'
            and status = 'completed'
            and product_name in ('C++', 'Java', 'Python')
        group by
            user_id
        having
            count(id) > 1
    )
order by
    id asc

第一次写文字表述,如有不对请各位大佬见谅:这里要注意,order_info表中的client_id才是和client表中的id匹配的,不是order_info.id = client.id 而是 order_info.client_id = client.id。

全部评论

相关推荐

05-12 17:28
已编辑
门头沟学院 硬件开发
ldf李鑫:不说公司名祝你以后天天遇到这样的公司
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务