在Oracle SQL中删除重复的行

时间:2019-05-24 05:56:34

标签: sql oracle

我已使用此代码选择重复的行,它正确了,

SELECT name, COUNT(name) 
  FROM emp
 GROUP BY name 
HAVING COUNT>1;

但是删除相同的所选行并没有帮助我。...

DELETE emp 
 WHERE name IN ( SELECT name, COUNT(name) 
                   FROM emp 
                  GROUP BY name 
                 HAVING COUNT >1);

1 个答案:

答案 0 :(得分:0)

从内部SELECT删除第二列,如下所示:

DELETE
  FROM emp
  WHERE name IN( SELECT name FROM emp GROPU BY name HAVING COUNT(name) > 1)