此题考点子查询,查询列是否包含了此项,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'
);



京公网安备 11010502036488号