Re: [HACKERS] DISTINCT ON: speak now or forever hold your peace

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Chris Bitmead <chris(at)bitmead(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org, pgsql-sql(at)postgresql(dot)org
Subject: Re: [HACKERS] DISTINCT ON: speak now or forever hold your peace
Date: 2000-01-26 18:34:38
Message-ID: Pine.LNX.4.21.0001260057190.9535-100000@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers 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(at)gmx(dot)net 75262 Uppsala
http://yi.org/peter-e/ Sweden

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2000-01-26 18:34:54 Re: [HACKERS] DISTINCT ON: speak now or forever hold your peace
Previous Message Peter Eisentraut 2000-01-26 18:34:29 Re: [HACKERS] Inheritance, referential integrity and other constraints

Browse pgsql-sql by date

  From Date Subject
Next Message Peter Eisentraut 2000-01-26 18:34:54 Re: [HACKERS] DISTINCT ON: speak now or forever hold your peace
Previous Message Palle Girgensohn 2000-01-26 15:07:50 Re: [SQL] Duplicate tuples with unique index