题解 | #购买行为分析3#

购买行为分析3

https://www.nowcoder.com/practice/44e9649f40f34e51886d7125860dd88a

此题考点子查询,查询列是否包含了此项,where 筛选列名 in (筛选条件)
select
    distinct 顾客ID
from
    销售订单表
where
    顾客ID in (
        select distinct
            顾客ID
        from
            销售订单表
        where
            产品 = 'ProductA'
    )
    and 顾客ID in (
        select distinct
            顾客ID
        from
            销售订单表
        where
            产品 = 'ProductB'
    )
    and 顾客ID not in (
        select distinct
            顾客ID
        from
            销售订单表
        where
            产品 = 'ProductC'
    );

全部评论

相关推荐

Lyxiho:浙江大学 加大加粗
点赞 评论 收藏
分享
01-18 09:26
已编辑
门头沟学院 Java
王桑的大offer:建议中间件那块写熟悉即可,写掌握 面试包被拷打到昏厥
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务