Re: [HACKERS] SELECT DISTINCT question - Mailing list pgsql-sql

From Tom Lane
Subject Re: [HACKERS] SELECT DISTINCT question
Date
Msg-id 5707.931641508@sss.pgh.pa.us
Whole thread Raw
In response to SELECT DISTINCT question  (Oleg Bartunov <oleg@sai.msu.su>)
Responses Re: [SQL] Re: [HACKERS] SELECT DISTINCT question
List pgsql-sql
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


pgsql-sql by date:

Previous
From: Oleg Bartunov
Date:
Subject: SELECT DISTINCT question
Next
From: Herouth Maoz
Date:
Subject: Re: [SQL] Bad date representation