Solved

Access Query - Find most recent date in table

Posted on 2008-10-14
2
1,571 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 ☠
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 12

Accepted Solution

by:
rgn2121 earned 500 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 62

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

710 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