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

Поиск
Список
Период
Сортировка
От Oleg Bartunov
Тема Re: [SQL] Re: [HACKERS] SELECT DISTINCT question
Дата
Msg-id Pine.GSO.3.96.SK.990711100405.2043V-100000@ra
обсуждение исходный текст
Ответ на Re: [HACKERS] SELECT DISTINCT question  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-sql
On Sat, 10 Jul 1999, Tom Lane wrote:

> Date: Sat, 10 Jul 1999 17:18:28 -0400
> From: Tom Lane <tgl@sss.pgh.pa.us>
> To: Oleg Bartunov <oleg@sai.msu.su>
> Cc: hackers@postgreSQL.org, pgsql-sql@postgreSQL.org
> Subject: [SQL] Re: [HACKERS] SELECT DISTINCT question 
> 
> 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;
> 

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



В списке pgsql-sql по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: [SQL] Re: [HACKERS] SELECT DISTINCT question
Следующее
От: qd@sea.com.ua
Дата:
Сообщение: Aggregates