Best-N aggregates - Mailing list pgsql-general

From Oliver Kennedy
Subject Best-N aggregates
Date
Msg-id E27AD664-1D82-46C9-A095-3E22F2FF6A44@cs.cornell.edu
Whole thread Raw
List pgsql-general
Hi,

I'm looking to write an aggregate of the form

compute_over_best_n ( A, B )

where I'm trying to compute a value over the first n (where n is data-
dependent) values in the input table, sorted over column A.  Column B
contains supplemental information used to determine n (that is, when
to stop the aggregate).  My first thought was to pass a sortop to
CREATE AGGREGATE, but the fact that I need column B prevents me from
using a sort.  Is there any way to trick postgres into only sorting
over the first parameter, without getting rid of the second?  Thanks.

- Oliver Kennedy

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: [ask] Return Query
Next
From: Kynn Jones
Date:
Subject: Scanning a large binary field