select distinct 客户 from 存货 as a where exists(
select 1 from 存货 as b where a.客户 = b.客户 and b.存货 = 'AA'
) and exists(
select 1 from 存货 as c where a.客户 = c.客户 and c.存货 = 'BB'
)
select 1 from 存货 as b where a.客户 = b.客户 and b.存货 = 'AA'
) and exists(
select 1 from 存货 as c where a.客户 = c.客户 and c.存货 = 'BB'
)
select 客户 from 销售表 a
where 存货='AA' and exists(
select 1 from 销售表 where 存货='BB' and 客户=a.客户)
from(select 客户 from 销售表 where 存货='AA' group by 客户
)a,(
select 客户 from 销售表 where 存货='BB' group by 客户
)b where a.客户=b.客户
join
INNER JOIN table AS b ON
b.存货='BB' AND b.客户=a.客户
-----------------
A AA 100
A BB 200
FROM 销售表
WHERE (存货 = 'AA') AND (客户 IN
(SELECT 客户
FROM 销售表
WHERE 存货 = 'BB'))
INNER JOIN table AS b ON
b.存货='BB' AND b.客户=a.客户
SELECT 客户, 存货, 数量
FROM 销售表
WHERE (客户 IN
(SELECT 客户
FROM 销售表
WHERE (存货 = 'AA') AND (客户 IN
(SELECT 客户
FROM 销售表
WHERE 存货 = 'BB')))
group by 客户
having(count(客户)=2)