I am using Access 2010 and have tried to search for an answer to the following question without success. I came across some SQL code, but had difficulty matching it to my specific needs. I don't know VBA/macros.
I need to build a query that will show all the fields for each customer, limited to all but the first 4 transaction dates - grouped by customer. In other words, if the customer has 9 transactions, I need details of the last 5; if the customer has 7 transactions, I need details of the last 3 transactions - by date.
Conversely, I also need to build a query that will give details of the first/last n (lets say 4) transactions - again, by date.
All help will be greatly appreciated!
CustomerID OrderID OrderDate Amount 1 1 1/1/15 200 1 2 1/6/15 300 2 3 1/2/15 50 1 4 1/3/15 60 3 5 1/2/15 900 2 6 1/9/15 400 1 7 1/12/15 300 3 8 1/3/15 100 2 9 2/1/15 200 1 10 2/2/15 66 3 11 2/15/15 90 2 12 2/11/15 500 2 13 2/9/15 100 1 14 2/9/15 300 3 15 2/28/15 250 1 16 2/27/15 444 2 17 2/16/15 700 3 18 2/20/15 300 3 19 1/19/15 650 2 20 1/30/15 125 3 21 1/1/15 700 1 22 2/3/15 100 1 23 2/5/15 250 3 24 2/7/15 190 2 25 2/22/15 900