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 |
4. Display the order number and client number from the ORDER table. Output the result in the format. Client <clientno> ordered <orderno>
What is a Segment ?
Database crashes. Corruption is found scattered among the file system neither of your doing nor of Oracles. What database recovery options are available? Database is in archive log mode.
Can select statements be used on views in oracle?
How will you write a query to get a 5th rank student from a table student_report?
How does one get the view definition of fixed views/tables?
What is the difference between 10g OEM and 11g OEM?
How does Oracle guarantee data integrity of data changes?
22. Display the order number, number of lines in the order, total number of items and total value for all orders that have a total value greater than $100
How do I uninstall oracle client from windows?
How to create a single index for multiple columns?
what is grid in Oracle 10g...