Results 1 to 4 of 4
  1. #1
    thousman is offline Novice
    Windows 10 Access 2019
    Join Date
    Aug 2022
    Location
    Palm Springs, CA
    Posts
    2

    Find, List and Count Duplicates in 4 different columns

    In advance, Thank You All as I appreciate any assistance. Also, if you can recommend any GOOD, FREE training that may be available I would appreciate it!



    So I have a database with 180,023 Records. I want to list and count All Duplicates in 4 different fields or (columns)
    The Table Name is "All Accounts Since 2013"
    Fields I want to search for Duplicates are "Patron Account Name, Primary Phone Display, Primary Email Address and Primary Address"

    Found this

    SELECT LastName, FirstName, Institution, Sum(1) as CNT
    FROM MyTableName
    GROUP BY LastName, FirstName, Institution
    HAVING (Sum(1) > 1)


    which I wrote like this

    SELECT Patron Account Name, Primary Phone Display, Primary Email Address, Primary Address 1 Sum(1) as CNT
    FROM All Accounts Since 2013
    GROUP BY Patron Account Name, Primary Phone Display, Primary Email Address, Primary Address
    HAVING (Sum(1) > 1)

    but it doesn't work. I get this message


    So I changed it to this and it worked (Sort of)

    SELECT [Patron Account Name], [Primary Phone Display], [Primary Email Address], [Primary Address 1], Sum(1) as CNT
    FROM [All Accounts Since 2013]
    GROUP BY [Patron Account Name], [Primary Phone Display], [Primary Email Address], [Primary Address 1]
    HAVING (Sum(1) > 1)

    I got this return, but I have no idea which column it is counting from, I want it to list the count for each column and list each occurrences.




    Also when I try to sort the Patron Account Name Column I get this message again

  2. #2
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    You would have to do it on field at the time, right now it gives you the count of records where all four fields are duplicated.

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  3. #3
    thousman is offline Novice
    Windows 10 Access 2019
    Join Date
    Aug 2022
    Location
    Palm Springs, CA
    Posts
    2
    Thanks Gicu, so can I do it all in one query and why do I get this weird me4ssage Syntax Error on Patron Account Name?

  4. #4
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    No, you need four queries, one for each field, and you do not show the error message, but it is likely caused by having spaces in the field names; open the query in SQL view and make sure you have the field name in the Order By clause wrapped in square brackets.

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

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

Similar Threads

  1. Find Duplicates
    By desnyder in forum Queries
    Replies: 30
    Last Post: 10-13-2020, 05:14 AM
  2. Replies: 2
    Last Post: 03-23-2018, 02:33 AM
  3. Replies: 3
    Last Post: 01-18-2016, 01:55 PM
  4. Need a count of a Duplicates Query
    By AudiA4_20T in forum Queries
    Replies: 1
    Last Post: 03-05-2013, 01:16 PM
  5. Don't count duplicates
    By shenberry in forum Queries
    Replies: 1
    Last Post: 10-27-2010, 09:28 PM

Tags for this Thread

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