Selecting a different column in a distinct select

O

Otac0n

Lets say I have a table like the fololowing;

----------
ID PrjID Name
Date
1 1 "TestProject"
Yesterday
2 1 "UpdatedNameForTestProject" Today
3 2 "ServerProject"
Yesterday
----------

how can i select just the most recent record from each distinct PrjID?

If i want to select the distinct PrjIds, this would give me the
following:

"Select Distinct Table.PrjID From Table"

----------
PrjID
1
2
----------

which is very usless.

I need to be able to select the MOST RECENT record from each distinct
ID.

Any help?

Hopefully,
John "otac0n" Gietzen
 
O

Otac0n

Sorry for the post. I just figured out a way:

SELECT *
FROM ProjectVersions as PV1
WHERE [Date] =
(SELECT Max(PV2.[Date])
FROM ProjectVersions as PV2
WHERE PV2.ProjectID = PV1.ProjectID)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top