Results 1 to 4 of 4
  1. #1
    dfeteau is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Mar 2013
    Posts
    2

    Max & Last in one Table

    I have a table, ACTIVE, that has over a million records. There are three important columns, FILENO, TRANS_DATE & CODE. I need a query that will give me a distinct FILENO with the CODE and last (or MAX) TRANS_DATE. This is what I have so far.



    Code:
    SELECT FILENO, Max(TRANS_DATE) AS L_SDATE, CODE AS L_SCODE
    FROM dbo_ACTIVE
    GROUP BY FILENO, CODE;
    The problem I'm having is that I'm getting distinct rows but i'm not getting the last or max date only and my guess is because i'm also grouping by CODE which has a number of different values. How do I get the LAST or MAX TRANS_DATE with whatever CODE is associated with it for each FILENO?

  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,652
    Is this what you're after?

    http://www.baldyweb.com/LastValue.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    dfeteau is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Mar 2013
    Posts
    2
    Yes it is Paul. Note to self: Stop Overthinking.

  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,652
    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. Replies: 4
    Last Post: 08-30-2012, 07:58 PM
  2. Replies: 8
    Last Post: 03-22-2012, 08:48 AM
  3. Replies: 2
    Last Post: 08-01-2011, 11:35 PM
  4. Replies: 2
    Last Post: 10-27-2009, 07:09 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