From owner-pgsql-sql@hub.org Sat Jul 10 16:31:14 1999
Received: from renoir.op.net (root@renoir.op.net [209.152.193.4])
by candle.pha.pa.us (8.9.0/8.9.0) with ESMTP id QAA03701
for <maillist@candle.pha.pa.us>; Sat, 10 Jul 1999 16:31:13 -0400 (EDT)
Received: from hub.org (hub.org [209.167.229.1]) by renoir.op.net (o1/$ Revision: 1.18 $) with ESMTP id QAA10295 for <maillist@candle.pha.pa.us>; Sat, 10 Jul 1999 16:29:57 -0400 (EDT)
From owner-pgsql-sql@hub.org Sat Jul 10 18:01:17 1999
Received: from renoir.op.net (root@renoir.op.net [209.152.193.4])
by candle.pha.pa.us (8.9.0/8.9.0) with ESMTP id SAA04878
for <maillist@candle.pha.pa.us>; Sat, 10 Jul 1999 18:01:16 -0400 (EDT)
Received: from hub.org (hub.org [209.167.229.1]) by renoir.op.net (o1/$ Revision: 1.18 $) with ESMTP id RAA12755 for <maillist@candle.pha.pa.us>; Sat, 10 Jul 1999 17:35:02 -0400 (EDT)
In-reply-to: Your message of Sun, 11 Jul 1999 00:16:39 +0400 (MSD)
<Pine.GSO.3.96.SK.990711000908.2043R-100000@ra>
Date: Sat, 10 Jul 1999 17:18:28 -0400
Message-ID: <5707.931641508@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
Sender: owner-pgsql-sql@postgreSQL.org
Precedence: bulk
Status: RO
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;
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...
regards, tom lane
From owner-pgsql-sql@hub.org Sun Jul 11 12:01:23 1999
Received: from renoir.op.net (root@renoir.op.net [209.152.193.4])
by candle.pha.pa.us (8.9.0/8.9.0) with ESMTP id MAA26263
for <maillist@candle.pha.pa.us>; Sun, 11 Jul 1999 12:01:22 -0400 (EDT)
Received: from hub.org (hub.org [209.167.229.1]) by renoir.op.net (o1/$ Revision: 1.18 $) with ESMTP id LAA14891 for <maillist@candle.pha.pa.us>; Sun, 11 Jul 1999 11:56:47 -0400 (EDT)
From owner-pgsql-hackers@hub.org Sun Jul 11 12:01:26 1999
Received: from renoir.op.net (root@renoir.op.net [209.152.193.4])
by candle.pha.pa.us (8.9.0/8.9.0) with ESMTP id MAA26269
for <maillist@candle.pha.pa.us>; Sun, 11 Jul 1999 12:01:25 -0400 (EDT)
Received: from hub.org (hub.org [209.167.229.1]) by renoir.op.net (o1/$ Revision: 1.18 $) with ESMTP id LAA15017 for <maillist@candle.pha.pa.us>; Sun, 11 Jul 1999 11:59:07 -0400 (EDT)
From owner-pgsql-sql@hub.org Sun Jul 11 12:01:16 1999
Received: from renoir.op.net (root@renoir.op.net [209.152.193.4])
by candle.pha.pa.us (8.9.0/8.9.0) with ESMTP id MAA26248
for <maillist@candle.pha.pa.us>; Sun, 11 Jul 1999 12:01:15 -0400 (EDT)
Received: from hub.org (hub.org [209.167.229.1]) by renoir.op.net (o1/$ Revision: 1.18 $) with ESMTP id LAA14635 for <maillist@candle.pha.pa.us>; Sun, 11 Jul 1999 11:52:26 -0400 (EDT)
In-reply-to: Your message of Sun, 11 Jul 1999 10:09:24 +0400 (MSD)
<Pine.GSO.3.96.SK.990711100405.2043V-100000@ra>
Date: Sun, 11 Jul 1999 11:38:43 -0400
Message-ID: <15129.931707523@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
Sender: owner-pgsql-sql@postgreSQL.org
Precedence: bulk
Status: RO
Oleg Bartunov <oleg@sai.msu.su> 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 <column name> 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
From owner-pgsql-sql@hub.org Tue Jul 13 18:02:01 1999
Received: from renoir.op.net (root@renoir.op.net [209.152.193.4])
by candle.pha.pa.us (8.9.0/8.9.0) with ESMTP id SAA07953
for <maillist@candle.pha.pa.us>; Tue, 13 Jul 1999 18:02:00 -0400 (EDT)
Received: from hub.org (hub.org [209.167.229.1]) by renoir.op.net (o1/$ Revision: 1.18 $) with ESMTP id RAA14528 for <maillist@candle.pha.pa.us>; Tue, 13 Jul 1999 17:46:12 -0400 (EDT)