I've been trying to wrap my head around creating aggregates in PostgreSQL (either 8.4 or 9.1) that accept one or more option parameters.
An example would be creating a PL/R
extension to compute the p-th quantile, with 0 <= p <= 1
. This would look something like quantile(x,p)
, and as part of a query:
select category,quantile(x,0.25)
from TABLE
group by category
order by category;
Where TABLE (category:text, x:float)
.
Suggestions?