From: Julian Scarfe <jas1@scigen.co.uk>
To: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: Re: [SQL] Finding the "most recent" rows
Date: Fri, 23 Apr 1999 10:30:14 +0000
Message-ID: <37204BB5.B6CD57B9@scigen.co.uk> (raw)
References: <17966.924794971@sss.pgh.pa.us>
Tom Lane wrote:
>
> SELECT DISTINCT ON place * FROM table ORDER BY place, time DESC;
>
> might do the right thing. It *seems* to select the first row for each
> value of place. I've never seen a spec for this feature, however, so
> I'm not sure if it's reliable or not...
Works a treat when I try it on the "real" database (using 6.4.2). It seems
very efficient. I didn't realise that "DISTINCT ON" worked that way with an
"ORDER BY".
I must say I'm overwhelmed by the variety of constructive responses to my
request. Thank you all very much. It beats the hell out of sitting as no 17
in a premium rate telephone queue for support from a vendor of a "commercial"
product.
--
Julian Scarfe
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: jas1@scigen.co.uk, tgl@sss.pgh.pa.us
Subject: Re: [SQL] Finding the "most recent" rows
In-Reply-To: <37204BB5.B6CD57B9@scigen.co.uk>
References: <17966.924794971@sss.pgh.pa.us> <37204BB5.B6CD57B9@scigen.co.uk>
* 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