Results 1 to 2 of 2
  1. #1
    ongjx is offline Novice
    Windows 8 Access 2013
    Join Date
    Dec 2014
    Posts
    1

    [HELP] Removing duplicates but keeping the lastest record


    Hi, I am new to access and really require some help with access. So currently i have queries and tables with several duplicated "username" records. What should i do to remove the record with a smaller value of "win/loss" and keep the duplicated "username" with a bigger value of "win/loss". Thanks in advance for your help!

    Click image for larger version. 

Name:	access.png 
Views:	9 
Size:	61.0 KB 
ID:	19112

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,944
    How many records are involved? The easiest approach is to do a sort and then review the records and manually delete the dupes. Automating this in a query will be tricky. It would be easier if there is a unique record ID in the table. An autonumber type field can serve. Try TOP N parameter to pull the record with lowest Win/Loss for each username. Review http://allenbrowne.com/subquery-01.html#TopN

    DELETE FROM [database with duplicates] WHERE ID IN (SELECT TOP 1 ID FROM [database with duplicates] AS Dupe WHERE Dupe.Username=[database with duplicates].Username ORDER BY Dupe.Username, Dupe.[Win/Loss])

    Be sure to test with a copy of the table.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. strategy for removing or keeping ex-clients
    By merlin777 in forum Database Design
    Replies: 5
    Last Post: 10-27-2014, 05:11 AM
  2. Removing Duplicates
    By hefferwolfe in forum Queries
    Replies: 1
    Last Post: 04-30-2014, 04:31 AM
  3. Merging & removing duplicates
    By Johin.b in forum Access
    Replies: 1
    Last Post: 08-09-2013, 03:07 PM
  4. Removing duplicates
    By DAVID W in forum Access
    Replies: 5
    Last Post: 12-21-2011, 03:15 PM
  5. Need help removing duplicates
    By warlock in forum Queries
    Replies: 1
    Last Post: 04-14-2011, 03:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums