Multiple parameters on aggregates?

Started by mlwover 24 years ago2 messages
#1mlw
markw@mohawksoft.com

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.

#2mlw
markw@mohawksoft.com
In reply to: mlw (#1)
Re: Multiple parameters on aggregates?

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