how to delete all duplicate records from a table using
subquery?
Answers were Sorted based on User's Feedback
delete from emp e1 where rowid >(select min(rowid) from emp
e2 where e1.empid=e2.empid)
Is This Answer Correct ? | 12 Yes | 5 No |
Answer / maninder
delete from abc where rowid not in (select max(rowid) from
abc group by column_name_with_dup.values.);
Is This Answer Correct ? | 10 Yes | 6 No |
Answer / noor
DELETE FROM T1
WHERE ROWID IN (SELECT ROWID FROM T1
WHERE ROWID NOT IN(SELECT MAX(ROWID) FROM
T1 GROUP BY C1,C2));
Is This Answer Correct ? | 1 Yes | 2 No |
Answer / edara satish
delete from
<<table_name>>
where rowid in
(select a.rowid
from <<table_name a,table_name b>>
where a.colname = b.colname
b.colname2 = b.colname2
......
...
a.colnamen = colnamen
order by .... desired colnames)
Is This Answer Correct ? | 2 Yes | 5 No |
Answer / lingareddy
by using below sub query delete duplicate all records:
DELETE FROM dept WHERE salary IN (
SELECT salary FROM dept GROUP BY salary HAVING ( COUNT(salary) > 1 ))
here is dept is the table name
salary is the column name
for any doubts about SQL contact with me
Thanks & Regards
Lingareddy.S
Is This Answer Correct ? | 0 Yes | 3 No |
Answer / aseem k
Tried and tested:
Table d:
7
8
7
DELETE FROM D WHERE ROWID IN (
SELECT DISTINCT MIN(ROWID) FROM D
WHERE DEPTNO IN
(SELECT DEPTNO FROM D GROUP BY DEPTNO
HAVING COUNT(DEPTNO)>1))
Is This Answer Correct ? | 1 Yes | 5 No |
How to retrieve the count of updated rows?
How to view all columns in an existing table?
how can find the second max sal for every group(i.e i want group the data based on key and find the second max sal for every group
Hi All, Recently I attended a interview for a developer position in an educational university. They asked me the a question, I answered somehow but I was not not satisfied myself. Can anybody reply for it? The question is: A business user comes to you directly with an urgent request:: there is a problem with some students not being able to re-enrol. It appears that ?something has gone wrong with the end-dating of some previous courses they had enrolled in, and this is preventing them from completing their on-line re-enrolments?. Fortunately the user has done some analysis on the situation, and has developed some code to change the end dates. They tell you that they have tested this code in the ?dev? environment, and it works fine. They are asking you to please get this implemented in production as soon as possible. What steps would you take in response to their request ? Thanks
How to shutdown your 10g xe server from command line?
How can you tell how much space is left on a given file system and how much space each of the file systems subdirectories take-up?
How to do paging with oracle?
Hi how Can I Add A Foreign key that references a table that has composit primary key ? example i had costumer table that has C_Id and SSN Both as PK and another table has C_Id that must refernece C_Id in Customers i done the usual way and got oracle error message about uniqeness any ideas plz
Will you be able to store pictures in the database?
How to use like conditions in oracle?
Explain integrity constraints?
How do I uninstall oracle 11g?