表名:RoleID,CorpID,Enabled
1   2            1
2   2            1
3   3            1
4   3            0查询处enabled全为1的Corpid的值?怎么写呢?

解决方案 »

  1.   

    seelct t.* from Role t where not exists(select 1 from Role where CorpID=t.CorpID and Enabled!=1)
      

  2.   

    select corpid from role where enabled<>1;
      

  3.   

    select  corpid from  role where enabled='1'
      

  4.   

    ID,CorpID,Enabled
    1   2            1
    2   2            1
    3   3            1
    4   3            0
    select * from tb where corpid not in (select distinct corpid from tb where enabled = 0)
      

  5.   

    select Corpid  from  Role where Enabled = '1'
      

  6.   

    select  corpid from  role where sum(Cast(enabled as int))/(count(*)*1.0)=1 group by corpid