oracle 去重sql

三种:

1.delete from table1 a where rowid not in(
    select max(rowid) from table1 b group by (去重字段));


2.delete from table1 a where rowid !=(
select max(rowid) from table b where a.name=b.name and b.sex=a.sex );



3.insert into tem_tab select distinct mobile from old_tab;
  drop table old_tab;
  rename tem_tab to old_tab;


4.delete from table1 where rowid in(
select rowid from (
select rowid,deptno,name,age, row_number() over(partition by deptno order by age desc) rn from emp_zh)where rn>1);---分组去重

猜你喜欢

转载自qnzhl.iteye.com/blog/2201628