Results 1 to 2 of 2
  1. #1
    stap is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Nov 2013
    Posts
    1

    Query to pull Max Value along with Multiple Columns

    I'm a newby to Access and have what is probably a very simple problem. I have a database with one table that tracks a company fleet of cars. I'm trying to write a query that will bring back the row with the highest mileage for each car. I need not only the car number, but also the driver name and date. The drivers for the various cars may be the same. For example, if this is the data,

    Car# Driver Date Mileage
    1 John Doe 1/1/2013 26351
    1 Peter Doe 5/2/2013 26398
    1 James Doe 6/1/2013 27896
    1 Peter Doe 6/1/2013 27904
    2 James Doe 3/4/2013 15234
    2 Sue Doe 5/2/2013 15865
    2 Jane Doe 6/4/2013 32564
    3 Sue Doe 5/2/2013 207
    3 Sue Doe 5/6/2013 506
    3 Peter Doe 6/5/2013 805

    I need the query to return this:

    Car# Driver Date Mileage
    1 Peter Doe 6/1/2013 27904
    2 Jane Doe 6/4/2013 32564
    3 Peter Doe 6/5/2013 805



    Any suggestions will be greatly appreciated!

  2. #2
    drunkenneo is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jun 2013
    Posts
    199
    Here u need to have two set to accomplish the task:

    1) qryMax: SELECT Car#, Driver, Max(Mileage) as Mileage
    FROM table
    GROUP BY Car#, Driver;

    and second set:

    SELECT t2.Car#,t2.Driver, t2.Mileage, t1.Date
    FROM qryMax t2 INNER JOIN table t1 ON (t2.Mileage = t1.Mileage) AND (t2.Driver = t1.Driver);

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

Similar Threads

  1. Replies: 8
    Last Post: 10-23-2013, 04:37 PM
  2. Replies: 7
    Last Post: 01-02-2013, 11:23 PM
  3. Query over multiple columns
    By aerabinovich in forum Queries
    Replies: 1
    Last Post: 11-23-2011, 10:43 AM
  4. Multiple columns from 1 query field
    By top1hat19 in forum Queries
    Replies: 3
    Last Post: 03-11-2011, 03:03 PM
  5. Replies: 1
    Last Post: 02-05-2010, 08:33 AM

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