Dear Steve:
You will need a correlated subquery (or a domain function) to do this.
I prefer to teach the correlated subquery approach because it is
portable to other SQL engines.
SELECT partnumber, [date], price
FROM ATable T
WHERE [date] =
(SELECT MAX([date]) FROM ATable T1
WHERE T1.partnumber = T.partnumber)
The last 2 lines in this query are the correlated subquery. It is
based on a simple query that would look like this:
SELECT partnumber, MAX([date])
FROM ATable
GROUP BY partnumber
In fact you could make an INNER JOIN to the above and achieve the same
results:
SELECT T1.partnumber, T1.[date], T1.price
FROM ATable T1
INNER JOIN (SELECT partnumber, MAX([date]) FROM ATable
GROUP BY partnumber) T2 ON T2.partnumber = T1.partnumber
In any case, if there exists more than one row in ATable (or whatever
you have named this table) for the same "latest" date (or date/time),
then you can certainly get more than one price for a given partnumber.
This is due to the fact that the answer is ambiguous in such a case.
Tom Ellison
Microsoft Access MVP
Ellison Enterprises - Your One Stop IT Experts