Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2019
    Posts
    2

    Question Grouping Common Values in one field with the lowest corresponding value in another...

    I'm not sure the subject line accurately describes what I am getting at.

    Example 1: I have some Columns, and in those columns, say Field 2 as some numbers, and Field 3 has some numbers. Fields, Doesn't matter, too much but I am likely to display it.

    Fields | Fields| Fields

    123 2 111
    123 4 111
    567 6 222
    567 8 222


    Example 2, what I want to see is:
    Field1 | Field2| Field3

    123 2 111
    567 6 222



    Is it possible to do this?

    Thanks for your insights!
    Last edited by JustMePatrick1979; 08-07-2019 at 02:38 PM. Reason: Fixing Spelling

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Looks like a simple aggregate (GROUP BY) query.

    SELECT Field1, Field3, Min(Field2) AS Min2 FROM table GROUP BY Field1, Field3;
    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
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    JMP,

    If you were describing your requirement and logic in simple, plain English---what would that be?
    I think June has made a great guess, but it is a guess.

    Welcome to the forum.

  4. #4
    Join Date
    Aug 2019
    Posts
    2
    Quote Originally Posted by orange View Post
    JMP,

    If you were describing your requirement and logic in simple, plain English---what would that be?
    I think June has made a great guess, but it is a guess.

    Welcome to the forum.
    That was my problem, trying to articulate it in simple, plain English.

    June was heading in right direction with their reply. I was trying to do it in an existing query. However, I needed to run it in a separate query with the source being the original query.

    Shortly after this post I found this post on a different forum: https://access-programmers.co.uk/for...d.php?t=135168 That really helped.


  5. #5
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,421
    That was my problem, trying to articulate it in simple, plain English.
    For each value in field1 I want the Max value from field2 and the value from field3 from the same record as Max of field2?
    Or did I mess that up?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Well, your example shows the min of field 2. It also shows Field3 is the same value for each Field1 group. Perhaps you need to provide more realistic data sample.

    Possibly need to use TOP N per group subquery. Review http://allenbrowne.com/subquery-01.html#TopN
    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: 4
    Last Post: 04-04-2018, 09:14 AM
  2. Replies: 1
    Last Post: 03-28-2013, 11:10 PM
  3. Replies: 2
    Last Post: 07-25-2012, 01:01 PM
  4. Replies: 4
    Last Post: 01-04-2012, 02:35 PM

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