表 函数
create table AA_TEST
(
aaaa NVARCHAR2(20),
bbbb NUMBER,
cccc NVARCHAR2(20)
) it
删除分两步:先保存知足要求的 io
delete from aa_test t where (t.aaaa,t.bbbb) not in ( table
select t1.aaaa,max(t1.bbbb) from aa_test t1 group by t1.aaaa); test
第二步再在第一步基础上删去重复记录 基础
delete from aa_test t where rowid not in(); select
第二种方式 ,使用开窗函数 tab
delete from AA_TEST where rowid in
(
select rowid from
(
select t.aaaa,t.bbbb,rowid, row_number() over(partition by t.aaaa order by t.bbbb desc) as cccc from AA_TEST t
)c
where c.cccc > 1
) di
备注: let
row_number()要配合over(order by xxx)进行使用,row_number()从1开始,为每一条分组记录返回一个数字