Re: [HACKERS] SELECT DISTINCT question

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Oleg Bartunov <oleg(at)sai(dot)msu(dot)su>
Cc: hackers(at)postgreSQL(dot)org, pgsql-sql(at)postgreSQL(dot)org
Subject: Re: [HACKERS] SELECT DISTINCT question
Date: 1999-07-10 21:18:28
Message-ID: 5707.931641508@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-sql

Oleg Bartunov <oleg(at)sai(dot)msu(dot)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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 1999-07-10 21:51:00 Re: [HACKERS] 6.5.1
Previous Message Oleg Bartunov 1999-07-10 20:44:02 Re: [HACKERS] 6.5.1

Browse pgsql-sql by date

  From Date Subject
Next Message welssen crow 1999-07-10 23:00:51 a problem of the postgresql ..
Previous Message Oleg Bartunov 1999-07-10 20:16:39 SELECT DISTINCT question