Re: Multiple parameters on aggregates?

From: mlw <markw(at)mohawksoft(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Multiple parameters on aggregates?
Date: 2001-08-19 15:23:08
Message-ID: 3B7FD9DC.F958485A@mohawksoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

mlw wrote:
>
> Just a suggestion, how much work would it be to accept multiple parameters on
> aggregate functions?
>
> For instance:
>
> select fubar(field1, field2) from table one group by field1;
>
> The reason I think that this is useful is that for some statistical operations,
> often times there is extra "per record" data that can affect how you calculate
> a value.

This would also be VERY helpful in a lot of OLAP type processing!

create function aggfunct( int4, int4, int4 )
returns int4
as '/usr/local/lib/pglib.so', 'aggfunct'
language 'c' ;

create function aggterm( int4 )
returns int4
as '/usr/local/lib/pglib.so', 'aggterm'
language 'c' ;

create aggregate agg1 ( basetype = integer,
sfunc1 = aggfunct, stype1 = integer,
finalfunc = aggterm,
initcond1 = 0 );

In the above example, parameters 1 and 2 to aggfunct are the standard aggregate
parameters are required by the "create aggrigate" syntax. At query time,
however, the additional parameter(s) is used in addition.

As an example of a more complex example, one could do something like this:

select mycube_agg(region, date, sales, product) from salesinfo group by region;

--
5-4-3-2-1 Thunderbirds are GO!
------------------------
http://www.mohawksoft.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2001-08-19 16:28:26 LIKE indexing
Previous Message Tom Lane 2001-08-19 15:22:08 Re: Guide to PostgreSQL source tree