Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-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

pgsql-hackers by date

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

pgsql-sql by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group