delete from table1 a where F2 < (select max(F2) from tabel1 where F1 = a.F1)
select * from table1 a where F2 = (select max(F2) from tabel1 where F1 = a.F1)
利用你的特殊条件只保留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
select F1,sum(F2) from t group by F1;
如果存在重复行: 如: A 1 A 1 A 0 B 0 B 0select F1,decode(sum(F2),0,0,1) from t group by F1;
select * from table where F2 = 1 or F2 not in (select distinct F2 from table where f2 = 1)
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) 如果要求效率好,还是要注意清理一下表里边的垃圾数据,保持好完整性
where F2 < (select max(F2) from tabel1 where F1 = a.F1)
where F2 = (select max(F2) from tabel1 where F1 = a.F1)
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
如:
A 1
A 1
A 0
B 0
B 0select F1,decode(sum(F2),0,0,1) from t group by F1;
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)
如果要求效率好,还是要注意清理一下表里边的垃圾数据,保持好完整性