Results 1 to 4 of 4
  1. #1
    knpaddac is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2017
    Posts
    22

    Duplicate Queries .... getting only the records I want to delete

    I have a database of basketball game information. In the process of uploading the data (that was in Excel) a pretty significant amount of games got put in twice. I've figured out how to seek out all instances of these with a duplicate query, but is there any way I could simply modify that query so it only returns the record with the higher key value (in this case it is called "GameID')? Currently the return may include 100 records but I am only wanting it to be 50. My end goal is to then be able to delete the unwanted records all in that single query. If it helps, below is the current SQL for the duplicate query as it stands now:




    SELECT GAMES_current.Season, GAMES_current.GameDate, GAMES_current.Winner, GAMES_current.Loser, GAMES_current.GameID, GAMES_current.WinScore, GAMES_current.LossScore
    FROM GAMES_current
    WHERE (((GAMES_current.Season) In (SELECT [Season] FROM [GAMES_current] As Tmp GROUP BY [Season],[GameDate],[Winner],[Loser] HAVING Count(*)>1 And [GameDate] = [GAMES_current].[GameDate] And [Winner] = [GAMES_current].[Winner] And [Loser] = [GAMES_current].[Loser]) And (GAMES_current.Season)=2017))
    ORDER BY GAMES_current.Season, GAMES_current.GameDate, GAMES_current.Winner, GAMES_current.Loser;

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Why would it matter which GameID is saved? A query using TOP N could return the latest ID record for each game. Review
    http://allenbrowne.com/subquery-01.html#TopN.
    Removing duplicates will likely involve saving records to another table. Review https://www.techrepublic.com/article...-access-query/
    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.

  3. #3
    JSR is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2018
    Location
    Reno, NV
    Posts
    41
    Deleting duplicates is much harder than simply eliminating their existence in a new table. Use query design, group by each data field, NewGroupID: max(GroupID), make new table. Rename NewGroupID to GroupID in the new table if you want.

  4. #4
    knpaddac is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2017
    Posts
    22
    I suppose it actually doesn't matter which is saved, I just need to isolate one half of each instance so that I can then delete them. Not certain if I am just dense, but I could not figure out how to get the Top N function to work with what I have.


    Quote Originally Posted by June7 View Post
    Why would it matter which GameID is saved? A query using TOP N could return the latest ID record for each game. Review
    http://allenbrowne.com/subquery-01.html#TopN.
    Removing duplicates will likely involve saving records to another table. Review https://www.techrepublic.com/article...-access-query/

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

Similar Threads

  1. Delete Duplicate Records?
    By aellistechsupport in forum Queries
    Replies: 4
    Last Post: 06-12-2017, 07:48 PM
  2. Replies: 4
    Last Post: 12-13-2016, 09:48 AM
  3. delete duplicate records
    By Jen0dorf in forum Access
    Replies: 9
    Last Post: 10-21-2016, 06:55 PM
  4. Delete duplicate records
    By samdahlr in forum Access
    Replies: 8
    Last Post: 07-28-2014, 08:25 AM
  5. Delete duplicate records
    By Zukster in forum Queries
    Replies: 1
    Last Post: 08-26-2009, 03:14 AM

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