Received: from sss.sss.pgh.pa.us (sss.pgh.pa.us [209.114.166.2] (may be forged)) by hub.org (8.9.3/8.9.3) with ESMTP id LAA04477; Sun, 11 Jul 1999 11:40:31 -0400 (EDT) (envelope-from tgl@sss.pgh.pa.us) Received: from sss.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.sss.pgh.pa.us (8.9.1/8.9.1) with ESMTP id LAA15131; Sun, 11 Jul 1999 11:38:44 -0400 (EDT) To: Oleg Bartunov cc: hackers@postgreSQL.org, pgsql-sql@postgreSQL.org Subject: Re: [SQL] Re: [HACKERS] SELECT DISTINCT question In-reply-to: Your message of Sun, 11 Jul 1999 10:09:24 +0400 (MSD) Date: Sun, 11 Jul 1999 11:38:43 -0400 Message-ID: <15129.931707523@sss.pgh.pa.us> From: Tom Lane Oleg Bartunov writes: > 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 "." Probably the grammar specifies just and not anything more complex after DISTINCT ON. It'd be risky to try to accept a general expression after ON, due to the silly decision to leave out any terminating punctuation. >> 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, No, there is no feature in SQL that allows DISTINCT on a subset of columns, period. This is not merely a matter of syntax, it's a fundamental semantic issue. > why just not to use standard > > select distinct(date), bytes from access_log; > > Or I'm missing here ? I don't think that does what you expect it to (hint: the parentheses are redundant). regards, tom lane