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'
)

解决方案 »

  1.   

    select 客户 from (select * from 销售表 where 存货='AA') A where 存货='BB'
      

  2.   


    select 客户 from 销售表 a
    where 存货='AA'  and exists(
    select 1 from 销售表 where 存货='BB' and 客户=a.客户)
      

  3.   

    select a.客户
    from(select 客户 from 销售表 where 存货='AA' group by 客户
    )a,(
    select 客户 from 销售表 where 存货='BB' group by 客户
    )b where a.客户=b.客户
      

  4.   

    select 客户 from table where 存货='AA' as a
    join
    INNER JOIN table AS b ON 
    b.存货='BB' AND b.客户=a.客户
      

  5.   

    如果返回结果为下面的呢?既有AA和BB存货销售的客户销售记录~~客户  存货  数量
    -----------------
    A     AA    100
    A     BB    200
      

  6.   

    SELECT     客户
    FROM        销售表
    WHERE     (存货 = 'AA') AND (客户 IN
                              (SELECT     客户
                                FROM          销售表
                                WHERE      存货 = 'BB'))
      

  7.   

    select 客户 from table where 存货='AA' as a
    INNER JOIN table AS b ON 
    b.存货='BB' AND b.客户=a.客户
      

  8.   

    如果返回结果为既有AA和BB存货销售的客户销售记录~~
    SELECT     客户, 存货, 数量
    FROM         销售表
    WHERE     (客户  IN
                              (SELECT     客户
                                    FROM        销售表
                                 WHERE     (存货 = 'AA') AND (客户 IN
                                                     (SELECT     客户
                                                      FROM          销售表
                                                      WHERE      存货 = 'BB')))
      

  9.   

    select a.* from table a,(select 客户,count(*) count from table ) b where a.客户=b.客户 and b.count>1
      

  10.   

    select 客户 from 销售表  where (存货=AA and 数量>0 ) or (存货=AA and 数量>0 ) 
    group by 客户
    having(count(客户)=2)