Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Access Query - Find most recent date in table

Posted on 2008-10-14
2
Medium Priority
?
1,603 Views
Last Modified: 2013-11-27
I have a table containing every invoice issued to a customer.  There are multiple records for each customer's business.

What I'm trying to produce is a query that will return a table containing only the most recent invoice record for each customer so I can follow-up customers who we've had no business with for more than 6 months.

The table has multiple fields but can you suggest a solution using the fields [Customer Ref#] and [Invoice_Date]?  I want to pull the whole record for their last business.

Normally I have no problem writing queries but this one has me stumped - I'm blaming it on a head cold :)

Thanks  M :o)
0
Comment
Question by:☠ MASQ ☠
2 Comments
 
LVL 12

Accepted Solution

by:
rgn2121 earned 2000 total points
ID: 22709508
I don't do much with Access, but I have a site I got to if I do that might help...Here is a little code from it.

Select MAX(Invoice_Date), Customer Ref#  from Table1 group by Customer Ref#;

Now, that will only return thos 2 fields so you will have to link it back up.

With A as (
Select MAX(Invoice_Date), Customer Ref#  from Table1 group by Customer Ref#;
)

Select *
From Table1, A
Where A.Customer Ref# =Table1.Customer Ref#
AND  A.Invoice_Date = Table1.Invoice_Date

Something like that...the site should help lay it out better.  I generally work through the errors, but Since I don't have to data to work against I am just throwing it together....
http://www.techonthenet.com/access/queries/max_query2.php
0
 
LVL 63

Author Comment

by:☠ MASQ ☠
ID: 22711317
Thanks
Select MAX(Invoice_Date), Customer Ref#  from Table1 group by Customer Ref#;
Needed a little tweaking but fundamentally solved the issue.  It was MAX() I had forgotten!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
If you’re using QODBC to update QuickBooks data from Microsoft® Access but Access is not showing the updated data, you could have set up QODBC incorrectly.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

876 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question