Results 1 to 3 of 3
  1. #1
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    727

    first three results

    All using access 2010. I have a table that has notes and foreign key from customer table(custid). When a note is entered; it is followed by a date. Some customers have 3 or more notes entries. I want to only keep the latest 3 entries and delete the records beyond 3. How can I write a query to get these results. I tried grouping but this only gives me the last one or max. If a customer has four note entries; I want to keep the last three. If a customer has only 1 or 2 note entries; I want all of the entries in the results. Can this be done and if so; how please. Thanks

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,956
    One way is with TOP N parameter. 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.

  3. #3
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    727
    Perfect. I knew it was something simple. Thanks a bunch!

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

Similar Threads

  1. Replies: 5
    Last Post: 05-21-2013, 02:21 PM
  2. Replies: 3
    Last Post: 05-02-2013, 10:36 AM
  3. Use SQL results
    By NISMOJim in forum Programming
    Replies: 7
    Last Post: 10-05-2012, 03:10 AM
  4. Replies: 6
    Last Post: 05-14-2012, 07:24 AM
  5. DLookup not getting results
    By Huddle in forum Access
    Replies: 15
    Last Post: 02-10-2012, 01:02 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