Re: [HACKERS] DISTINCT ON: speak now or forever hold your peace - Mailing list pgsql-sql

From Peter Eisentraut
Subject Re: [HACKERS] DISTINCT ON: speak now or forever hold your peace
Date
Msg-id Pine.LNX.4.21.0001260143120.9535-100000@localhost.localdomain
Whole thread Raw
In response to DISTINCT ON: speak now or forever hold your peace  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: [HACKERS] DISTINCT ON: speak now or forever hold your peace  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-sql
On 2000-01-24, Tom Lane mentioned:

> If I don't hear loud hollers very soon, I'm going to eliminate the
> DISTINCT ON "feature" for 7.0.  As previously discussed, this feature
> is not standard SQL and has no clear semantic interpretation.

Our documents say that DISTINCT ON is equivalent to GROUP BY. I still
don't see why that wouldn't be true. You can always rewrite

select distinct on a a,b from test

as

select a, xxx(b) from test group by a

where xxx is some aggregate function (presumably min or max).

You can also rewrite

select distinct on a a,b,c from test

as

select a, b, c from test group by a, b, c

or using some aggregates here as well. At least you can control your
results that way.

-- 
Peter Eisentraut                  Sernanders väg 10:115
peter_e@gmx.net                   75262 Uppsala
http://yi.org/peter-e/            Sweden



pgsql-sql by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: [HACKERS] DISTINCT ON: speak now or forever hold your peace
Next
From: Tom Lane
Date:
Subject: Re: [HACKERS] DISTINCT ON: speak now or forever hold your peace