Results 1 to 2 of 2

Thread: Duplicates

  1. #1
    Join Date
    Apr 2004
    Location
    Melbourne
    Posts
    144

    Unanswered: Duplicates

    i've imported a number of spreadsheets into a database
    the schema is

    directoryid firstname, lastname, extension
    703168 Andrew Lim 78094
    703154 Joseph Egan 78888
    704548 Andrew Lim 78094

    I realized the spreadsheet had a large number of duplicates. How can i delete the duplicates ?
    like deleting directoryid 703168 only.

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    This syntax will give you a recordset with unique attributes:
    Code:
    select	min(directoryid) as directoryid,
    	firstname,
    	lastname,
    	extension
    from	YourTable
    group by firstname,
    	lastname,
    	extension
    You can either left join this to your master table as a subquery and delete where the subquery directorid is null, or you can select this recordset into a temporary table, truncate/delete records from your existing table, and then insert the saved records back into it.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •