Re: [HACKERS] SELECT DISTINCT question - Mailing list pgsql-sql

From Hannu Krosing
Subject Re: [HACKERS] SELECT DISTINCT question
Date
Msg-id 378BA6B1.2B226DDB@trust.ee
Whole thread Raw
In response to SELECT DISTINCT question  (Oleg Bartunov <oleg@sai.msu.su>)
Responses Re: [HACKERS] SELECT DISTINCT question  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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 by date:

Previous
From: "Hub.Org News Admin"
Date:
Subject: ...
Next
From: Tom Lane
Date:
Subject: Re: [HACKERS] SELECT DISTINCT question