Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2021
    Posts
    5

    Simple group by query

    Hi guys, propably a simple question for you, but I don't get it. My Table:

    pkey1 data1 compare1


    pkey2 data2 compare2
    pkey3 data3 compare3
    pkey4 data1 compare4
    ...

    So for one data entry, there are various data entries, and various compare entries for each data entry. What I need ist a tavle with Distinct data, and its Max(compare) value.
    I was pretty sure it works like this: Select data, Max(compare) From table Group by data..., but Access keeps sendinf me error messages.
    Thanks for any help
    Thorsten

  2. #2
    Join Date
    Apr 2017
    Posts
    1,679
    Code:
    SELECT data, MAX(compare) AS MaxCompare FROM YourTable GROUP BY data ORDER BY data
    Edit (Edit again! It looks like pbaldy is right about this!)
    (replace YourTable with your table name, and data and compare with according field names)
    Last edited by ArviLaanemets; 08-02-2021 at 07:56 AM.

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    It would be helpful to know what the error message is. Your pseudo query looks about right. I don't think you want to include pkey, presuming it's a unique primary key, or you'll get no grouping.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 8
    Last Post: 03-16-2016, 10:11 AM
  2. Replies: 2
    Last Post: 10-07-2015, 12:28 PM
  3. Replies: 6
    Last Post: 06-09-2015, 09:51 AM
  4. Simple Group By Query w a placeholder record?
    By murfeezlaw in forum Queries
    Replies: 2
    Last Post: 11-24-2012, 09:59 AM
  5. query group by over another group by?
    By gap in forum Queries
    Replies: 2
    Last Post: 07-04-2011, 12:59 AM

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