Exforsys

Online Training

How to delete duplicate rows from a table

This is a discussion on How to delete duplicate rows from a table within the Oracle Tutorials forums, part of the Articles and Tutorials category; Hi friends, can any body please tell me how can i delete duplicate records from a table . If the table ...


Go Back   Exforsys > Articles and Tutorials > Oracle Tutorials

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 06-26-2005, 03:16 PM
Junior Member
 
Join Date: Jun 2005
Posts: 3
athermaliq is on a distinguished road
How to delete duplicate rows from a table

Hi friends,
can any body please tell me how can i delete duplicate records from a table .
If the table I have is with the following data

SNO SNAME
--------------------------------
1001 ATHER
1001 ATHER
1001 ATHER
1001 ATHER
1001 ATHER

is it possible to delete 4 records and keep any one record, plese reply if someone has answer.

Thanx& Regards
Ather
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 06-27-2005, 06:38 AM
Junior Member
 
Join Date: Jun 2005
Posts: 2
kevinsmith is on a distinguished road
To delete Duplicate rows In a table

Hi Ather,
Assuming the table name as TEST with data in it as.

SNO SNAME
---- ---------
1001 ATHER
1001 ATHER
1001 ATHER
1001 ATHER
1001 ATHER

Query to delete duplicate records can be written as given below

SQL> delete from test a
where rowid <> ( select max(rowid)
from test b
where a.sno = b.sno
and a.sname = b.sname )

Hope it helps

Thnx&Regards
Kevin
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 08-25-2005, 04:28 AM
Junior Member
 
Join Date: Aug 2005
Posts: 3
silpi jain is on a distinguished road
delete duplicate record

delete from tablename e1 where rowid>(select min(rowid) from tablename e2
where e1.code=e2.code);
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 12-05-2005, 05:45 AM
Junior Member
 
Join Date: Dec 2005
Posts: 1
parult is on a distinguished road
Deleting Duplicate records

Hi,

Try this out

SELECT sno,
COUNT(sno) AS NumOccurrences
FROM <tblname>
GROUP BY sno
HAVING ( COUNT(sno) > 1 )


Quote:
Originally Posted by athermaliq
Hi friends,
can any body please tell me how can i delete duplicate records from a table .
If the table I have is with the following data

SNO SNAME
--------------------------------
1001 ATHER
1001 ATHER
1001 ATHER
1001 ATHER
1001 ATHER

is it possible to delete 4 records and keep any one record, plese reply if someone has answer.

Thanx& Regards
Ather
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 01-07-2006, 02:13 AM
Junior Member
 
Join Date: Dec 2005
Posts: 10
sriharid is on a distinguished road
delete from test where rowid not in (select min(rowid) from test
group by sno sname);
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 01-17-2006, 01:03 AM
Junior Member
 
Join Date: Jan 2006
Posts: 2
harsha1780 is on a distinguished road
how to delete duplicate rows from the following table

hi guys, i would like to know how to write a query to delete duplicate rows from the below table, friends reply me pls

KNO KNAME
---- -------
555 ssss
333 dddd
555 ssss
333 dddd
555 ssss
333 dddd
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 07:23 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2004 - 2007 Exforsys Inc. All rights reserved.