Re: [SQL] Re: [HACKERS] SELECT DISTINCT question

From: Oleg Bartunov <oleg(at)sai(dot)msu(dot)su>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: hackers(at)postgreSQL(dot)org, pgsql-sql(at)postgreSQL(dot)org
Subject: Re: [SQL] Re: [HACKERS] SELECT DISTINCT question
Date: 1999-07-11 06:09:24
Message-ID: Pine.GSO.3.96.SK.990711100405.2043V-100000@ra
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-sql

On Sat, 10 Jul 1999, Tom Lane wrote:

> Date: Sat, 10 Jul 1999 17:18:28 -0400
> 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: [SQL] Re: [HACKERS] SELECT DISTINCT question
>
> 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;
>

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(at)sai(dot)msu(dot)su, http://www.sai.msu.su/~megera/
phone: +007(095)939-16-83, +007(095)939-23-83

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jan Wieck 1999-07-11 13:46:26 Re: [ADMIN] Re: [HACKERS] Problems with src/pl/tcl/mkMakefile.tcldefs.sh.in in 6.5
Previous Message Oleg Bartunov 1999-07-11 05:57:03 Re: [HACKERS] 6.5.1

Browse pgsql-sql by date

  From Date Subject
Next Message Herouth Maoz 1999-07-11 14:37:03 Re: [SQL] uncorrelated subqueries
Previous Message welssen crow 1999-07-10 23:00:51 a problem of the postgresql ..