Surely this must be easy?

danb

Registered User.
Local time
Today, 03:39
Joined
Sep 13, 2003
Messages
98
Anyone know how to select only distinct names from the following table, taking only the name with the most recent year of birth:

Id Name YearOfBirth
1 Bob 1979
2 Barry 1945
3 Karl 2000
4 Barry 1966
5 Martin 1970
6 Martin 1951


I want to return the following results:

1 Bob 1979
3 Karl 2000
4 Barry 1966
5 Martin 1970

If I do an ordinary SELECT DISTINCT it returns duplicates of the names due to the non-distinct YearOfBirths.

It's got to be simple right?
 
Select name, max(yearofbirth) from MyTable group by name
 

Users who are viewing this thread

Back
Top Bottom