How to: Select Last Record for Each Record ID

My current query retrieves the following data

<Current Resultset>

id             LastContactDate

1              10-jan-06
1              11-jan-06
1              12-jan-06
2              10-feb-06
2              11-feb-06
2              12-feb-06

I need to be able to select only the latest date for each record id.

<Required Resultset>

id             LastDateContact

1              12-jan-06
2              12-feb-06

Thanks in advance
Who is Participating?
Anthony PerkinsConnect With a Mentor Commented:
You need to requery the database with something like this:

Select id, MAX(LastContactDate)
From YourTableName
Group by id
Aneesh RetnakaranDatabase AdministratorCommented:
Hi jfmckenzie,

SELECT ID, MAX(LastContactDate)LastContactDate
FRoM urTable

Aneesh R!
jfmckenzieAuthor Commented:
Thanks guys. Both comments correct, not sure how to allocate points so just accepted first answer.
Anthony PerkinsCommented:
>>not sure how to allocate points <<
See here from the EE Help:

More than one Expert helped solve my problem. What do I do?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.