Selecting ONLY the most recent record...

  • Thread starter Thread starter Brad Pears
  • Start date Start date
B

Brad Pears

I have a situation where management wants a report that lists notes for
customers - but they only want the MOST RECENT note for each customer to
show...

Customers and Notes are in a one-many relationship linked by field
CustomerID

I know there is a "select FIRST" SQL clause but it does not appear to work
in Access 2000 (what my project is based on)

What would be a good way to go about obtaining the results I am looking for?

Thanks, Brad

Thanks, Brad
 
Brad said:
I have a situation where management wants a report that lists notes
for customers - but they only want the MOST RECENT note for each
customer to show...

Customers and Notes are in a one-many relationship linked by field
CustomerID

I know there is a "select FIRST" SQL clause but it does not appear to
work in Access 2000 (what my project is based on)

What would be a good way to go about obtaining the results I am
looking for?

Does the Notes table include a date field indicating when the record was
created? You need either that or an incrementing field per record or else
there is no way to determine which record is the most recent. There is
nothing that automatically keeps track of entry orderin a database.
 
Yes there is a datestamp field in the notes table so I can order by that
field in descending order...

Brad
 
Brad said:
Yes there is a datestamp field in the notes table so I can order by
that field in descending order...

Then use the query...

SELECT TOP 1 *
FROM TableName
ORDER BY DateField DESC
 
What I really want is the "top 1" for each unique customer ID in the notes
table.

The query you gave me returns only one row for all the notes that are in
there. I need the most recent note for each customer.

Can this be maybe done somehow in a nested query??

Note: in the Notes table, there are multiple notes for each customer.

Thanks, Brad
 

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

Back
Top