SQL Query to retrieve highest item up to a point in a group
- by James
The best way of describing this is I have a table of people with their names and ages.  Assume that people with the same surname are from the same family.  I need a query in oracle which will retrieve a list of the oldest person in each family, but not older than a certain age.
Table: person
name      surname         age
===============================
James     Smith           23
Sarah     Powell          17
Barry     Smith           31
Mark      Smith           35
Mary      Smith           18
Bob       Powell          30
How do I retrieve the oldest person in each family under 30?
Results I'm after
name      surname         age
===============================
James     Smith           23
Sarah     Powell          17