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

全部评论

相关推荐

10-02 19:29
已编辑
浙江科技大学 运营
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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