select * from tablename where 产品 in(
select 产品 from tablename group by 产品 having max(结算情况)=0)

解决方案 »

  1.   

    declare @tab table(产品 varchar(20),结算情况 bit,金额 int)
    insert @tab values('0001',0,100)
    insert @tab values('0001',1,50)
    insert @tab values('0002',0,100)
    insert @tab values('0002',0,100)
    select * from @tabselect * from @tab where 产品 not in(select 产品 from @tab where 结算情况=1)
      

  2.   

    select * 
    from ABC
    where 产品 not in (select distinct 产品 from ABC where 结算情况=1)
      

  3.   

    Select * from tablename where 产品   
    not in (select 产品 from tablename where 结算情况=1)
      

  4.   

    我是这么写的
    select * from ABC where b=0 and a not in (select a from ABC where b<>0)哪一个效率高啊
      

  5.   

    select * 
    from ABC
    where 产品 not in (select distinct 产品 from ABC where 结算情况=1)
      

  6.   

    select * 
    from ABC
    where 产品 not in (select distinct 产品 from ABC where 结算情况=1)