delete t from A as t where exists(select * from A where e=t.e and b>t.b)
如果你用的是ORACLE数据库系统,可以试一下这个:(hr.ee 为表名的引用,HR为模式,EE为表名)delete from hr.ee where rowid not in ( select rowid from hr.ee t1 where t1.b= ( select max(b) from hr.ee where t1.e=e group by e ) )
create table t as select n.* from (select e,max(b) as b from A group by e) m,A AS n where m.e=n.e and m.b=n.b union select * from A where 1=3; drop table a; rename t to a; 如果是做数据整理,不是嵌在程序里的话,我都这么写.
delete t from A as t where exists(select * from A where e=t.e and b>t.b)
(
select rowid from hr.ee t1 where t1.b=
(
select max(b) from hr.ee where t1.e=e group by e
)
)
as
select n.*
from (select e,max(b) as b from A group by e) m,A AS n
where m.e=n.e
and m.b=n.b
union
select * from A where 1=3;
drop table a;
rename t to a;
如果是做数据整理,不是嵌在程序里的话,我都这么写.