Re: [HACKERS] SELECT DISTINCT question

Поиск
Список
Период
Сортировка
От Hannu Krosing
Тема Re: [HACKERS] SELECT DISTINCT question
Дата
Msg-id 378BA6B1.2B226DDB@trust.ee
обсуждение исходный текст
Ответ на SELECT DISTINCT question  (Oleg Bartunov <oleg@sai.msu.su>)
Ответы Re: [HACKERS] SELECT DISTINCT question  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-sql
Oleg Bartunov wrote:
> 
> I got a problem with query:
> 
> select distinct (date), bytes  from access_log;
> 
> which works but not as I expect. I thought this query will select
> all rows with distinct values of 'date' column, but it get
> distinct pairs 'date, bytes' . From documnetation I see
> 
> "DISTINCT will eliminate all duplicate rows from the selection.
> DISTINCT ON column will eliminate all duplicates in the specified column;
> this is equivalent to using GROUP BY column.

If it is equivalent to GROUP BY then it should allow only aggregates 
in non-distinct columns, like:

select distinct on date date, sum(bytes) from access_log;

If it does not, then it should be files as a bug imho.

-----------------
Hannu


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

Предыдущее
От: "Hub.Org News Admin"
Дата:
Сообщение: ...
Следующее
От: Tom Lane
Дата:
Сообщение: Re: [HACKERS] SELECT DISTINCT question