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 |
I have a table emp. There is only one column in the table. In that , there are only three rows in that column. The value in the first row is 'A' and the value in the second row is 'B' and the third row is 'C'. Now, my question is , How will you write a select query to display the output as B C A Note: order by cannot be used coz it gives us output as CBA. But the output should be BCA.
How to start instance with a minimal initialization parameter file?
normally database take to refresh time 2 hours. but client asked iwant to refresh with in 5 min that same database. do you have any option in BO and Oracle? explain me briefly...kavi
i must get table name, constraint type, constrain name with using concads "||" and it must be in string type, then with join processes i need code please help immidiately
If a parameter is used in a query without being previously defined, what diff. exist betw. report 2.0 and 2.5 when the query is applied ?
What is Parallel Server ?
10. Display the client number, order date and shipping date for all orders where the shipping date is between three and six months after the order date.
i want department wise maxmum salary and empolyee name
find out the second highest salary?
55 Answers Cognizant, Nucsoft, Oracle, TCS, Wondersoft,
can you explain performance tunning in oracle(sql,PL/SQL)
How to pass parameters to procedures in oracle?
i wrote a pl/sql procedure. it must run every sunday 4.40 How can i schedule it with the help of dbms_jobs (or another other procedure with out creating bat file,exe file)