most recent 5 records

S

Simon

I have a form/table for customers and one for orders. They share a common id.
When I run a query to join them, I get multiple records for each customer
depending on the number of orders they have placed. Is there a way to have it
only return the last 5 records with the most recent order? I cannot query by
dates, because customer #1 might have placed last order 1 year ago, while
customer
#2 may have placed 15 orders during that time or customer #3 may have 100
orders until today. I only need the most recent 5 orders per customer for my
report. Any assistance would be greatly appreciated.
 
A

Allen Browne

You can do this easily in a form or report, by using a subform/subreport.

Main form bound to Customers table.
Subform bound to a query like this:
SELECT TOP 5 Orders.* FROM Orders ORDER BY OrderDate DESC;
 
S

simon

How about if I want to report all customers , but just limited 5 last order
of each customer.
Simon:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top