Hi gudmrng to all,
This is Sathish.
Q. A table contains 50 records in that 25 recs are duplicate how to delete duplicate records?
Send queries to this mail inturi86@gmail.com
This is a discussion on duplicate records deletion? within the Databases forums, part of the category; Hi gudmrng to all, This is Sathish. Q. A table contains 50 records in that 25 recs are duplicate how to delete duplicate records? Send queries to this mail inturi86@gmail.com...
Hi gudmrng to all,
This is Sathish.
Q. A table contains 50 records in that 25 recs are duplicate how to delete duplicate records?
Send queries to this mail inturi86@gmail.com
Hello, Which database you are using .. Cheers, Chandra
Dear All.
finding the duplicate records :
select * from emp
where sal in (select sal from emp
group by sal
having count(1)>1);
2.duplicate records deletion:
delete emp
where sal in (select sal from emp
group by sal
having count(1)>1)
Thanks &Regards,
kethinenisarath
Last edited by kethinenisarath; 03-08-2011 at 02:47 PM.
Hi,
If your database is oracle then by using ROWID psuedo column you can delete the duplicate records.see below syntax
delete fromwhere rowid not in(select max(rowid) from group by .
eg:i want to delete the duplicate records from emp table.
delete from emp where rowid not in(select max(rowid) from emp group by empno);
Thanks,
vl
DELETE FROM table_name WHERE rowid NOT IN (SELECT max(rowid) FROM table_name GROUP BY id);
for further study on PL SQL you can visit.
It will be helpful especially when deletion is related to the date column:
DELETE FROM Table t1 WHERE COLUMN_NAME < (SELECT MAX(COLUMN_NAME) FROM Table T2 WHERE T1.COL= T2.COL);»
Thanks!!