Retrieve most recent date.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a table with a bunch of fields, including a repeated secondary key (a link to another table) and a date field. I need a query which will show only the most recently dated record, for each value of the secondary key.
And I can't work out how to do it...
 
You might try a query whose SQL looks something like this:

SELECT
[Your Table].*
FROM
[Your Table]
WHERE
[Your Table].[Your Date Field] =
(SELECT
Max([Self].[Your Date Field])
FROM
[Your Table] AS [Self]
WHERE
[Self].[Your Linking Field] = [Your Table].[Your Linking Field])

See

http://www.mvps.org/access/queries/qry0020.htm

for other alternatives to this approach.

Chiral said:
I have a table with a bunch of fields, including a repeated secondary key
(a link to another table) and a date field. I need a query which will show
only the most recently dated record, for each value of the secondary key.
 
Correctio

NOT First of id field

SELECT MAX(DATEFIELD), SECONDID FROM MYTABLE GROUP BY SECONDID
 
Back
Top