Re: [HACKERS] DISTINCT ON: speak now or forever hold your peace - Mailing list pgsql-sql

From Peter Eisentraut
Subject Re: [HACKERS] DISTINCT ON: speak now or forever hold your peace
Date
Msg-id Pine.LNX.4.21.0001260057190.9535-100000@localhost.localdomain
Whole thread Raw
In response to Re: [HACKERS] DISTINCT ON: speak now or forever hold your peace  (Chris Bitmead <chris@bitmead.com>)
List pgsql-sql
On 2000-01-25, Chris Bitmead mentioned:

> I think what I really meant was...
> 
> SELECT DISTINCT ON firstname firstname, age ORDER BY age.
> 
> Which would find the youngest person called "fred", the youngest person
> called "paul", the youngest person called "jim" etc etc. which your
> limit example wouldn't do.

SELECT firstname, min(age) FROM x GROUP BY firstname [ ORDER BY min(age) ]

-- 
Peter Eisentraut                  Sernanders väg 10:115
peter_e@gmx.net                   75262 Uppsala
http://yi.org/peter-e/            Sweden




pgsql-sql by date:

Previous
From: Palle Girgensohn
Date:
Subject: Re: [SQL] Duplicate tuples with unique index
Next
From: Peter Eisentraut
Date:
Subject: Re: [HACKERS] DISTINCT ON: speak now or forever hold your peace