题解 | #购买行为分析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'
    );

全部评论

相关推荐

1个小白:可以考虑投一下字节
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务