Need help with eliminating duplicate entries in a query.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • LH731
    New Member
    • May 2013
    • 3

    Need help with eliminating duplicate entries in a query.

    I am pretty new at Access, but below is the code for my query. I am trying to obtain the most current meeting/contact date and its details for each meeting/contact. A few of the companies show up several times on the query even though I have chosen to "group by" company name. It works correctly on some but not others.

    Code:
    SELECT Max([Meetings/Contacts].[Meeting Date]) 
    AS [MaxOfMeeting Date], [Meetings/Contacts].[Company Name], [Meetings/Contacts].[Meeting  Time], [Meetings/Contacts].[Meeting Location], [Meetings/Contacts].[Our Contact], [Meetings/Contacts].[Met/Conversation With], [Meetings/Contacts].[Meeting Summary]
    FROM [Meetings/Contacts]
    GROUP BY [Meetings/Contacts].[Company Name], [Meetings/Contacts].[Meeting  Time], [Meetings/Contacts].[Meeting Location], [Meetings/Contacts].[Our Contact], [Meetings/Contacts].[Met/Conversation With], [Meetings/Contacts].[Meeting Summary]
    ORDER BY [Meetings/Contacts].[Company Name];
    Last edited by Rabbit; May 24 '13, 03:41 PM. Reason: Please use code tags when posting code.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    That's because you're also grouping by [Meetings/Contacts].[Meeting Time], [Meetings/Contacts].[Meeting Location], [Meetings/Contacts].[Our Contact], [Meetings/Contacts].[Met/Conversation With], [Meetings/Contacts].[Meeting Summary]. Grouping means that it's going to summarize on each distinct value combination of the group by fields.

    What you need to do is drop all those other group by fields and get just the max date for each company. You then join that back to the table on the company and date to get the details of just those meetings.

    Comment

    • LH731
      New Member
      • May 2013
      • 3

      #3
      That worked, but now I'm in design view of the query and have added the meetings/contacts table. How do I join a query to a table?

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        The same way you join a table to a table.

        Comment

        • LH731
          New Member
          • May 2013
          • 3

          #5
          Think I've got it now. Thanks sooo much for your help!!

          Comment

          • Rabbit
            Recognized Expert MVP
            • Jan 2007
            • 12517

            #6
            Not a problem, good luck with the reset of your project!

            Comment

            Working...