Results 1 to 3 of 3
  1. #1
    Lounger
    Join Date
    Mar 2003
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Last 5 records (Access 2K)

    Is there a syntax in SQL that will allow me to select only the last 5 transactions record for each customer?

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Last 5 records (Access 2K)

    That is largely dependent on the record structure. Assuming that you have a method for sorting them that shows you the most recent record first, you can use the TOP option to specify the top 1,2 5, 10 or whatever. You can also set that in the QBE view by displaying the properties for the query and replacing ALL in Top Values with 5.
    Wendell

  3. #3
    3 Star Lounger
    Join Date
    Mar 2001
    Location
    Minneapolis, Minnesota, USA
    Posts
    262
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Last 5 records (Access 2K)

    Assuming you have a time/date stamp, transaction# and customer# in the transaction table, base a new query on the transaction table and bring down the fields in the order that I listed them, making sure the time/date stamp is the furtherst to the left. Sort descending by date/time stamp. Add criteria so you select transactions for the customer you wish. Right click in the top pane of the query designer and chose Properties. You'll see a Top Values property you can set -- enter the number 5 to get the last five transactions.
    <font face="Comic Sans MS"><font color=blue>~Shane</font color=blue></font face=comic>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •