ids from grouped rows

From: Lindsay <hellolindsay(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: ids from grouped rows
Date: 2005-07-20 12:46:38
Message-ID: e1f838770507200546208a47fc@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Lets say i do this:

SELECT name, MAX(age)
FROM Person
GROUP BY name

This will group people who have the same name together, and return the
highest age for each group. I want to be able to find the id for the
person with the highest age in each group -

Ideally, it would be something like this

SELECT name, MAX(age), id_for_row_with_max_age
FROM Person
GROUP BY name

Anyone know how to do this?

Lindsay

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Weinzierl Stefan 2005-07-20 14:09:23 Re: ids from grouped rows
Previous Message Andreas Joseph Krogh 2005-07-20 07:21:26 Re: echo/printf function in plpgsql