From: Herouth Maoz <herouth@oumail.openu.ac.il>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] Finding the "most recent" rows
Date: Thu, 29 Apr 1999 13:28:38 +0300
Message-ID: <l03130302b34ddfaad0be@[147.233.159.109]> (raw)
In-Reply-To: <21889.924884968@sss.pgh.pa.us>
References: <199904231442.IAA17294@trillium.nmsu.edu>
At 19:29 +0300 on 23/04/1999, Tom Lane wrote:
> I recall now that when I first heard of "SELECT DISTINCT ON field"
> I objected that the results weren't well-defined (since it's not clear
> how DISTINCT will choose which tuple to return). It might be that the
> SQL spec requires the first tuple to be chosen for each value of
> "field", which would allow the user to control the results by inserting
> a preceding ORDER BY step --- or skip the ORDER BY, if he doesn't really
> care which tuple he gets. That'd actually be a pretty cool design.
> Anyone have an SQL spec handy to check it?
DISTINCT ON is a non-standard structure. Your initial assertion, that it
will return different results in different implementations holds true.
Standard SQL should return the same result sets (order not important unless
ORDER BY was mentioned).
Tables are considered as unordered sets. There can not be anything in the
standard that relies on the order in the table. And what do you mean by
inserting a preceding ORDER BY step?
Herouth
--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma
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: herouth@oumail.openu.ac.il, tgl@sss.pgh.pa.us
Subject: Re: [SQL] Finding the "most recent" rows
In-Reply-To: <l03130302b34ddfaad0be@[147.233.159.109]>
References: <199904231442.IAA17294@trillium.nmsu.edu> <l03130302b34ddfaad0be@[147.233.159.109]>
* 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