Results 1 to 5 of 5
  1. #1
    McArthurGDM is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    215

    Query Type w/ Highest Value

    Hi,



    I'm not sure how to go about designing a query that would allow this particular query output. It's beyond my SQL level. Assume I have a table, assignments, as such:

    ASSIGNMENTS
    ID Students Scores
    1 A 74
    2 A 66
    3 A 36
    4 B 73
    5 B 94
    6 C 68
    7 C 59
    8 C 94
    9 C 85
    10 D 9


    I want to query out the highest score for each particular student. That is, I want my output as such:

    QUERY
    ID Students Scores
    1 A 74
    5 B 94
    8 C 94
    10 D 9


    Any help in being able to create a query output like this would be appreciated!

    Thanks,

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,847
    Try
    Code:
    Select students, Max(scores)
    from YourTable
    Group By Students
    Order By students
    see w3schools sql Max

  3. #3
    McArthurGDM is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    215
    Thanks,

    This is a good start and on the right track. Unfortunately, I would still need to reference the particular ID associated with each record that I pull out - and grouping causes an issue with this.

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,847
    Try

    Code:
    SELECT *
    FROM assignments
    WHERE scores IN (
    		SELECT Max(scores) AS MaxScore
    		FROM ASSIGNMENTS
    		GROUP BY Students
    		ORDER BY students
    		)

  5. #5
    McArthurGDM is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    215
    Thank you,

    I had to tweak it a little and had some syntax issues, but I got it to work. Thanks for the help.

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

Similar Threads

  1. Query for only the highest level
    By NISMOJim in forum Queries
    Replies: 5
    Last Post: 07-14-2014, 10:25 PM
  2. Replies: 1
    Last Post: 02-13-2012, 04:58 PM
  3. Find 2nd or 3rd highest record with a query
    By K Roger in forum Queries
    Replies: 1
    Last Post: 12-19-2011, 11:27 PM
  4. Query to return only the row containing the highest date.
    By eric.opperman1@gmail.com in forum Queries
    Replies: 4
    Last Post: 03-22-2011, 08:42 PM
  5. query to find the highest value in a field
    By jhjarvie in forum Queries
    Replies: 0
    Last Post: 09-02-2008, 02:27 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