Received: from trends.net (root@clio.trends.ca [209.47.148.2]) by hub.org (8.9.3/8.9.3) with ESMTP id LAA05079; Sun, 11 Jul 1999 11:41:38 -0400 (EDT) (envelope-from oleg@sai.msu.su) Received: from ra.sai.msu.su (ra.sai.msu.su [158.250.29.2]) by trends.net (8.8.8/8.8.8) with ESMTP id CAA21557; Sun, 11 Jul 1999 02:23:01 -0400 (EDT) Received: from ra (ra [158.250.29.2]) by ra.sai.msu.su (8.9.1/8.9.1) with SMTP id KAA18412; Sun, 11 Jul 1999 10:09:24 +0400 (MSD) Date: Sun, 11 Jul 1999 10:09:24 +0400 (MSD) From: Oleg Bartunov X-Sender: megera@ra To: Tom Lane cc: hackers@postgreSQL.org, pgsql-sql@postgreSQL.org Subject: Re: [SQL] Re: [HACKERS] SELECT DISTINCT question In-Reply-To: <5707.931641508@sss.pgh.pa.us> Message-ID: Organization: Sternberg Astronomical Institute (Moscow University) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Sat, 10 Jul 1999, Tom Lane wrote: > Date: Sat, 10 Jul 1999 17:18:28 -0400 > From: Tom Lane > To: Oleg Bartunov > Cc: hackers@postgreSQL.org, pgsql-sql@postgreSQL.org > Subject: [SQL] Re: [HACKERS] SELECT DISTINCT question > > Oleg Bartunov 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