Results 1 to 4 of 4
  1. #1
    mkc80 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2012
    Posts
    56

    Delete Duplicate records based on one column

    I need to delete all rows where you have same Supplier-ID, Customer-ID, Order1_Date, Order2_Date, Name BUT different Type.
    Only when we have 2 records with Type-1 and Type-2 for the Type column, we need to delete one of these records.

    I need help writing this query.



    Thanks in advance.
    Supplier-ID Customer-ID Order1_Date Order2_Date Order3_Date Order4_Date Name Type
    00001 001 3/30/2011 4/6/2011 3/30/2011 4/6/2011 John Type-1
    00001 001 3/30/2011 4/6/2011 4/3/2011 4/6/2011
    John
    Type-2

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    50,423
    Are there only the 2 types? Will each combination always have a type 1 record? Maybe:

    DELETE FROM tablename WHERE Type>"Type-1";
    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
    mkc80 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2012
    Posts
    56
    Yes, each combination will always have Type-1, if I use the above query I get the following error:"Could not delete from specified tables"
    The query I am running is
    Delete FROM tablename WHERE Type > "Type-1" Group by Supplier-ID, Customer-ID, Order1_Date, Order2_Date, Name;

    Actually the tablename (or the table from which I am trying to delete) is a query in itself.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    50,423
    I assume you used your actual query name in place of 'tablename'. That error means the query is not editable. Also, Grouping in a DELETE action does not make sense. Grouping is used to summarize data in a Totals (aggregate) SELECT 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.

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

Similar Threads

  1. Replies: 2
    Last Post: 11-08-2017, 09:04 AM
  2. Replies: 2
    Last Post: 04-13-2012, 12:53 AM
  3. Delete Duplicate Records Based on Criteria
    By chadd in forum Queries
    Replies: 2
    Last Post: 02-07-2012, 04:24 PM
  4. Replies: 3
    Last Post: 05-03-2011, 01:36 PM
  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