how to delete all duplicate records from a table using
subquery?

Answers were Sorted based on User's Feedback



how to delete all duplicate records from a table using subquery?..

Answer / dharmendra

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

how to delete all duplicate records from a table using subquery?..

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

how to delete all duplicate records from a table using subquery?..

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

how to delete all duplicate records from a table using subquery?..

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

how to delete all duplicate records from a table using subquery?..

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

how to delete all duplicate records from a table using subquery?..

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 delete all duplicate records from a table using subquery?..

Answer / sunil

delete emp where empno not in(select distinct empno from emp);

For example we have duplicates in empno column then write
query like above...whatever column u want u can write..

Is This Answer Correct ?    0 Yes 11 No

Post New Answer

More Oracle General Interview Questions

How to execute a stored program unit?

0 Answers  


What is the difference between formal parameters and actual parameters?

0 Answers  


Maximum how many triggers can be updated in table ?

5 Answers   Accenture, Cap Gemini,


How remove data files before opening a database?

0 Answers  


How to use like conditions in oracle?

0 Answers  






What happens if recursive calls get out of control?

0 Answers  


How to select the name of employee who is getting maximum sal with out using subquery

15 Answers  


What are the different types of failures that occur in Oracle database?

0 Answers   HCL,


How to rename an index?

0 Answers  


dear sir/madam, i have done my engg in 2007 after that i did oracle course (sql,plsql,forms,reports) .from 2008 to 2009 i searched job but didnt got.so i planned to move to sales field & i gone to dubai.till now i m in sales only.now i want to shift my career in to IT industry.but now people are not hiring as fresher.so i planned put fake 1 + exp. is it good or bad or any other way is there to enter in IT.please suggest me or call me 09632087338.

3 Answers  


what is the bitmap index?

3 Answers  


When system tablespace is created?

0 Answers  


Categories
  • Oracle General Interview Questions Oracle General (1789)
  • Oracle DBA (Database Administration) Interview Questions Oracle DBA (Database Administration) (261)
  • Oracle Call Interface (OCI) Interview Questions Oracle Call Interface (OCI) (10)
  • Oracle Architecture Interview Questions Oracle Architecture (90)
  • Oracle Security Interview Questions Oracle Security (38)
  • Oracle Forms Reports Interview Questions Oracle Forms Reports (510)
  • Oracle Data Integrator (ODI) Interview Questions Oracle Data Integrator (ODI) (120)
  • Oracle ETL Interview Questions Oracle ETL (15)
  • Oracle RAC Interview Questions Oracle RAC (93)
  • Oracle D2K Interview Questions Oracle D2K (72)
  • Oracle AllOther Interview Questions Oracle AllOther (241)