Re: DISTINCT ON without ORDER BY

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Jasen Betts <jasen(at)xnet(dot)co(dot)nz>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: DISTINCT ON without ORDER BY
Date: 2009-04-22 06:27:24
Message-ID: 20090422062724.GA21883@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Apr 21, 2009 at 12:11:26PM +0000, Jasen Betts wrote:
> > Is there a way to acheive the above result without a sort and without a
> > self-join?
>
> anyway you could possibly write an agregate function that returns a
> copy of the row with the highest id?

Put that way it sounds like something for a window function. Not sure
if they can use a HashAggrgate though.

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Please line up in a tree and maintain the heap invariant while
> boarding. Thank you for flying nlogn airlines.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message S Arvind 2009-04-22 13:16:22 Reg: Logging log_min_duration_statement
Previous Message A. Kretschmer 2009-04-22 04:57:36 Re: No connection could be made because the target machine actively refused it