Re: DISTINCT to get distinct *substrings*?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Christoph Pingel <ch(dot)pingel(at)web(dot)de>
Cc: pgsql general <pgsql-general(at)postgresql(dot)org>
Subject: Re: DISTINCT to get distinct *substrings*?
Date: 2006-08-08 20:29:32
Message-ID: 12848.1155068972@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Christoph Pingel <ch(dot)pingel(at)web(dot)de> writes:
> Am 08.08.2006 um 19:49 schrieb Nikolay Samokhvalov:
>> don't use "DISTINCT ON" at all, it's evil :-) (why?
>> http://chernowiki.ru/index.php?node=38#A13

> Thanks for the good advice! From reading this, it seems to be a
> *really* bad thing. And I didn't get it from the official
> documentation. :-)

That page is complaining about DISTINCT ON as it was defined in 1999.
It's a lot harder to shoot yourself in the foot now:

regression=# select distinct on (ten) hundred from tenk1 order by unique2;
ERROR: SELECT DISTINCT ON expressions must match initial ORDER BY expressions

I don't deny that it's nonstandard and pretty ugly, but sometimes it's
just really hard to solve a problem any other way.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Chris Hoover 2006-08-08 20:41:04 Why is default value not working on insert?
Previous Message John DeSoi 2006-08-08 20:29:06 Re: read only transaction, temporary tables