Results 1 to 4 of 4
  1. #1
    Conceptz is offline Novice
    Windows XP Access 2003
    Join Date
    May 2012
    Posts
    4

    Query to show latest records

    Hi all,

    I have the following table:
    prod_name price year
    apple $1.00 2012
    orange $1.00 2012
    grape $1.00 2012
    grape $2.00 2013

    I need to write a query that will retrieve the records for each product using the most recent info (year). So the result of the query will look like this:
    prod_name price year
    apple $1.00 2012
    orange $1.00 2012
    grape $2.00 2013

    The query I have right now (below) retrieves everything and not just the latest year, it works if I just select the prod_name and year, but fails if I select all 3 fields (prod_name, price, year).

    Here is my query:
    Code:
    SELECT prod_name, price, max(year) as max_of_year
    FROM tbl_list
    Group by prod_name, price;
    Thanks!

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Conceptz is offline Novice
    Windows XP Access 2003
    Join Date
    May 2012
    Posts
    4
    Quote Originally Posted by pbaldy View Post
    Thank you so much, got it to work with this link!

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Happy to help, and welcome to the site by the way!
    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. Query by form does not show all records
    By 011billyw in forum Forms
    Replies: 20
    Last Post: 03-20-2012, 05:10 PM
  2. Limit query to only show the latest record
    By marcustofeles in forum Queries
    Replies: 12
    Last Post: 10-05-2011, 08:06 AM
  3. How to not show duplicate records in query?
    By JimmD43 in forum Queries
    Replies: 3
    Last Post: 05-29-2011, 02:54 PM
  4. How to fetch latest records from table
    By India62 in forum Access
    Replies: 13
    Last Post: 05-19-2011, 11:43 PM
  5. Latest Date Records
    By Rick West in forum Queries
    Replies: 1
    Last Post: 09-25-2009, 11:16 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