Received: from kodu.home.ee (isdn-54.uninet.ee [194.204.0.118]) by hub.org (8.9.3/8.9.3) with ESMTP id QAA85166; Tue, 13 Jul 1999 16:41:50 -0400 (EDT) (envelope-from hannu@trust.ee) Received: from trust.ee (hannu@localhost [127.0.0.1]) by kodu.home.ee (8.8.7/8.8.7) with ESMTP id XAA00497; Tue, 13 Jul 1999 23:50:57 +0300 Sender: hannu@kodu.home.ee Message-ID: <378BA6B1.2B226DDB@trust.ee> Date: Tue, 13 Jul 1999 23:50:57 +0300 From: Hannu Krosing Organization: Trust-O-Matic =?iso-8859-1?Q?O=DC?= X-Mailer: Mozilla 4.5 [en] (X11; U; Linux 2.2.6 i686) X-Accept-Language: en MIME-Version: 1.0 To: Oleg Bartunov CC: hackers@postgreSQL.org, pgsql-sql@postgreSQL.org Subject: Re: [HACKERS] SELECT DISTINCT question References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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