如何删除存在多个重复记录中的一个
比如表内容为no jg
a 2
v 1
a 2
f 3
我想删除一个no=a,jg=2的记录。但是用delete from table where no=a,jg=2;的话会把两个都删除。我感觉要用pl/sql。请问有什么方法么? DELETE FROM EMP E
WHERE E.ROWID > (SELECT MIN(X.ROWID)
FROM EMP X
WHERE X.EMP_NO = E.EMP_NO); create table i(no varchar2(3),id number)
a 2
v 1
a 2
f 3
方法一
delete from i a where a.rowid<(select max(rowid) from i b where a.no=b.no)
方法二
delete from i where rowid in (select rowid from (select no,row_number()over(partition by no order by no) rn from i )
where rn>1) delete from i a where a.rowid<(select max(rowid) from i b where a.no=b.no)
页:
[1]