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

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [SQL] Re: [HACKERS] SELECT DISTINCT question
Дата
Msg-id 15129.931707523@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: [SQL] Re: [HACKERS] SELECT DISTINCT question  (Oleg Bartunov <oleg@sai.msu.su>)
Список pgsql-hackers
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


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

Предыдущее
От: wieck@debis.com (Jan Wieck)
Дата:
Сообщение: Re: [ADMIN] Re: [HACKERS] Problems with src/pl/tcl/mkMakefile.tcldefs.sh.in in 6.5
Следующее
От: Oleg Bartunov
Дата:
Сообщение: Re: [SQL] Re: [HACKERS] SELECT DISTINCT question