From: Oleg Bartunov <oleg@sai.msu.su>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: hackers@postgreSQL.org
Cc: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] Re: [HACKERS] SELECT DISTINCT question
Date: Sun, 11 Jul 1999 10:09:24 +0400 (MSD)
Message-ID: <Pine.GSO.3.96.SK.990711100405.2043V-100000@ra> (raw)
In-Reply-To: <5707.931641508@sss.pgh.pa.us>
On Sat, 10 Jul 1999, Tom Lane wrote:
> Date: Sat, 10 Jul 1999 17:18:28 -0400
> From: Tom Lane <tgl@sss.pgh.pa.us>
> To: Oleg Bartunov <oleg@sai.msu.su>
> Cc: hackers@postgreSQL.org, pgsql-sql@postgreSQL.org
> Subject: [SQL] Re: [HACKERS] SELECT DISTINCT question
>
> Oleg Bartunov <oleg@sai.msu.su> writes:
> > discovery=> select distinct on date,bytes from access_log;
> > ERROR: parser: parse error at or near ","
>
> The syntax for SELECT DISTINCT ON is just as brain-damaged as the
> functionality itself: there's no comma after the column name.
> You want
>
> select distinct on date date,bytes from access_log;
>
thanks, this works. But why parser complains about such query:
discovery=> select distinct on a.date a.date, a.bytes from access_log a;
ERROR: parser: parse error at or near "."
In this query I could just omit '.', but in more complex query
I probably could need one.
> The reason the functionality is brain-damaged is that there's no way to
> know which tuple out of the set of tuples with a given "date" value will
> be the one returned.
>
> SELECT DISTINCT ON is not in SQL92, and I think it shouldn't be in
> Postgres either...
I'm not an SQL expert, but if it works and this feature is in standard
but only syntax is diffrent, why just not to use standard
select distinct(date), bytes from access_log;
Or I'm missing here ?
Regards,
Oleg
>
> regards, tom lane
>
_____________________________________________________________
Oleg Bartunov, sci.researcher, hostmaster of AstroNet,
Sternberg Astronomical Institute, Moscow University (Russia)
Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/
phone: +007(095)939-16-83, +007(095)939-23-83
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: oleg@sai.msu.su, tgl@sss.pgh.pa.us, hackers@postgreSQL.org
Subject: Re: [SQL] Re: [HACKERS] SELECT DISTINCT question
In-Reply-To: <Pine.GSO.3.96.SK.990711100405.2043V-100000@ra>
References: <5707.931641508@sss.pgh.pa.us> <Pine.GSO.3.96.SK.990711100405.2043V-100000@ra>
* 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