Re: Top N within groups?

From: hubert depesz lubaczewski <depesz(at)depesz(dot)com>
To: Klint Gore <kgore4(at)une(dot)edu(dot)au>
Cc: Ivan Sergio Borgonovo <mail(at)webthatworks(dot)it>, pgsql-general(at)postgresql(dot)org
Subject: Re: Top N within groups?
Date: 2008-07-12 15:07:22
Message-ID: 20080712150722.GA3535@depesz.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Jul 11, 2008 at 01:24:28PM +1000, Klint Gore wrote:
> Can someone familiar with the source for DISTINCT ON comment on how hard
> it would be to add another parameter to return more than one row?

you can make top-n per group quite easily using the technique described
here:
http://www.depesz.com/index.php/2007/08/17/rownum-anyone-cumulative-sum-in-one-query/

best regards,

depesz

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Wm. Stewart 2008-07-12 15:59:42 Wiki: FreeOpenSourceSoftware.org
Previous Message Scott Marlowe 2008-07-12 13:12:55 Re: Default fill factor for tables?