From: Tom Lane <tgl@sss.pgh.pa.us>
To: Hannu Krosing <hannu@trust.ee>
Cc: hackers@postgreSQL.org
Cc: pgsql-sql@postgreSQL.org
Subject: Re: [HACKERS] SELECT DISTINCT question
Date: Tue, 13 Jul 1999 17:31:48 -0400
Message-ID: <24413.931901508@sss.pgh.pa.us> (raw)
In-Reply-To: <378BA6B1.2B226DDB@trust.ee>
Hannu Krosing <hannu@trust.ee> writes:
>> "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.
It does not. Whether that is a bug is hard to say, since there is no
standard I know of that says what it *is* supposed to do.
If you look at the select_distinct_on regress test outputs, I bet you
will be even less happy:
QUERY: SELECT DISTINCT ON string4 two, string4, ten
FROM tmp
ORDER BY two using <, string4 using <, ten using <;
two|string4|ten
---+-------+---
0|AAAAxx | 0
0|HHHHxx | 0
0|OOOOxx | 0
0|VVVVxx | 0
1|AAAAxx | 1
1|HHHHxx | 1
1|OOOOxx | 1
1|VVVVxx | 1
(8 rows)
That's not exactly my idea of "distinct" values of string4 ---
but apparently whoever made up the regress test thought it was OK!
Can anyone defend this feature or provide a coherent definition
of what it's supposed to be doing? My urge to rip it out is
growing stronger and stronger...
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, hannu@trust.ee, hackers@postgreSQL.org
Subject: Re: [HACKERS] SELECT DISTINCT question
In-Reply-To: <24413.931901508@sss.pgh.pa.us>
References: <378BA6B1.2B226DDB@trust.ee> <24413.931901508@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox