select * from 表名 where 状态 = 1

解决方案 »

  1.   

    select * from tab where 状态=1 and 品种 not in (select 品种 from tab where 状态=0 )group by 品种 状态
      

  2.   

    select count(*)-sum(if(状态=1,1,0)) as 结果 from 表 group by 品种 HAVING 结果=0
      

  3.   

    select * 
    from tb
    where 状态=0
    and 品种 not in (select 品种 from tb where 状态=1)
    group by 品种

    select 品种,count(distinct 品种) as aa
    from tb
    group by 品种
    having count(distinct 品种)>=2
      

  4.   

    特别是上面一种
    select * 
    from tb
    where 状态=0
    and 品种 not in (select 品种 from tb where 状态=1)
    group by 品种感觉确实没什么错误,而且select 品种 from tb where 状态=1单独查询也可以,把“select 品种 from tb where 状态=1”换成一组数组后也可以,但是放在一起就不行了,不知道为什么?
      

  5.   

    品种 状态
    A     0
    A     1
    B     0
    B     0
    B     0
    B     1
    C     1
    查询出来是
    品种 状态
    C     1 
    只有1的状态就查出来
    你不是要这样的结果吗?
      

  6.   

    那你不妨分两步做,
    select 品种 
    into tb1
    from tb 
    where 状态=1
    group by 品种select * from tb 
    where 品种 not in (select 品种 from tb1)
    group by 品种
      

  7.   

    redstorm11(今年不能回家过年!郁闷!很郁闷!严重郁闷!)
    的语句没有问题啊,你用的什么数据库??
      

  8.   

    xuzuning(唠叨) 是正解PS 刚才要下班了,没注意看