Exforsys
+ Reply to Thread
Results 1 to 7 of 7

How to delete duplicate rows from a table

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

  1. #1
    athermaliq is offline Junior Member Array
    Join Date
    Jun 2005
    Answers
    2

    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


  2. #2
    kevinsmith is offline Junior Member Array
    Join Date
    Jun 2005
    Answers
    2

    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


  3. #3
    silpi jain is offline Junior Member Array
    Join Date
    Aug 2005
    Answers
    3

    delete duplicate record

    delete from tablename e1 where rowid>(select min(rowid) from tablename e2
    where e1.code=e2.code);


  4. #4
    parult is offline Junior Member Array
    Join Date
    Dec 2005
    Answers
    1

    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



  5. #5
    sriharid is offline Junior Member Array
    Join Date
    Dec 2005
    Answers
    6
    delete from test where rowid not in (select min(rowid) from test
    group by sno sname);


  6. #6
    harsha1780 is offline Junior Member Array
    Join Date
    Jan 2006
    Answers
    1

    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


  7. #7
    anilkumar2010's Avatar
    anilkumar2010 is offline know nothing Array
    Join Date
    Oct 2011
    Location
    amerpet
    Answers
    7
    i think we can't oit but we supress the duplicated date from which column u want by DISTINCT keyword.


    •    Sponsored Ads



Latest Article

Network Security Risk Assessment and Measurement

Read More...