I need help with Access Function

I have a simple table called Table:

ID      Code      Status                               StatusCode      EndDate
1      A              Input                               1                      9/10/2013
2      A              Verified                               2                      9/11/2013
3      A              Checked and approved       3                      9/12/2013
4      A              Closed                               4                      9/16/2013
5      B              Input                               1                      9/11/2013
6      B              Verified                               2                      9/12/2013
7      B              Checked and approved       3                      9/17/2013
8      C              Input                               1                     9/11/2013
9      C              Verified                               2                     9/12/2013
10      C              Checked and approved       3                     9/15/2013
11      C              Closed                               4                     9/16/2013

I want to retrieve only the last EndDate grouped by Code:
I was trying to use Max function,  and it does work only for Code and EndDate, if i add the rest of the fields it returned all rows of the data
so it should be:

4      A              Closed                               4                      9/16/2013
7      B              Checked and approved       3                      9/17/2013
11      C              Closed                               4                      9/16/2013
Roman FAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Something similar to this will work:
SELECT A.ID, A.Code, A.Status, A.StatusCode, A.EndDate
(SELECT StatusCode, MAX(EndDate) AS _maxEndDate FROM Table Group BY StatusCode) B
ON A.StatusCode = B.StatusCode AND A.EndDate = B._maxEndDate

Open in new window

You can also use Top:
SELECT Table.ID, Table.Code, Table.Status, Table.StatusCode, Table.EndDate
FROM [Table]
WHERE (((Table.ID) In (Select TOP 1 T.ID FROM [Table] as T Where (T.Code = [Table].[Code]) Order By T.EndDate Desc)));

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Roman FAuthor Commented:
Thank you very much
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.