pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ragnar Hafstaư <gnari@simnet.is>
To: Lindsay <hellolindsay@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: ids from grouped rows
Date: Wed, 20 Jul 2005 14:50:12 +0000
Message-ID: <1121871013.17734.9.camel@localhost.localdomain> (raw)
In-Reply-To: <e1f838770507200546208a47fc@mail.gmail.com>
References: <e1f838770507200546208a47fc@mail.gmail.com>

On Wed, 2005-07-20 at 08:46 -0400, Lindsay wrote:

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

how about:
  select distinct on (name) name, age, id 
         from person
         order by name, age desc;



gnari

 





view thread (3+ messages)

Message-ID: <1121871013.17734.9.camel@localhost.localdomain>
Permalink:  ../1121871013.17734.9.camel@localhost.localdomain/
Also on:    postgresql.org/message-id/1121871013.17734.9.camel@localhost.localdomain

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: gnari@simnet.is, hellolindsay@gmail.com
  Subject: Re: ids from grouped rows
  In-Reply-To: <1121871013.17734.9.camel@localhost.localdomain>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox