select * from t where not exists(select 1 from t t1 where t1.f1=t.f1 and t1.f2<>t.f2 and t1.f2=1)

解决方案 »

  1.   

    delete from table1 a 
     where F2 < (select max(F2) from tabel1 where F1 = a.F1)
      

  2.   

    select *  from table1 a 
     where F2 = (select max(F2) from tabel1 where F1 = a.F1)
      

  3.   

    利用你的特殊条件只保留1 的特性,有以下解决方法:
    select table.* from table,
    (select maxx(F2) as F2,F1 from table group by F1) table_2
    where table.F1=table_2.F1 and table.F2=table_2.F2
      

  4.   

    select F1,sum(F2) from t group by F1;
      

  5.   

    如果存在重复行:
    如:
    A   1
    A   1
    A   0
    B   0
    B   0select F1,decode(sum(F2),0,0,1) from t group by F1;
      

  6.   

    select * from table where F2 = 1 or F2 not in (select distinct F2 from  table where f2 = 1)
      

  7.   

    运行了一下好象还是“ skystar99047(天星) ”的方案速度快点。不知还有没有其他更好的方案,因为我的数据量在100万条以上,并且还需要进行按输入的条件进行查询和按F1字段排序等操作
      

  8.   

    skystar99047(天星)的想法又创意
      

  9.   

    select f1,max(f2) from t group by f1;
      

  10.   

    select f1,f2 from tab where f2=1
    union all
    select f1,f2 from tab t where f2=0 and not exists(select 1 from tab where f1=t.f1 and f2=1);
    另外建立索引:(f2,f1)和(f1,f2)
    如果要求效率好,还是要注意清理一下表里边的垃圾数据,保持好完整性