Aggregate functions with two or more arguments?

Поиск
Список
Период
Сортировка
От Brian K Boonstra
Тема Aggregate functions with two or more arguments?
Дата
Msg-id 832EF96F-D614-11D8-A42D-00039319807C@boonstra.org
обсуждение исходный текст
Ответ на Re: determining supported timezones  (Robert Treat <xzilla@users.sourceforge.net>)
Ответы Re: Aggregate functions with two or more arguments?  (Mike Mascari <mascarm@mascari.com>)
Список pgsql-general
Let's say that I want to efficiently compute something like a weighted
standard deviation (the actual formula I have in mind is slightly more
complicated).   The kind of SQL statement I want to have work is
something like

     SELECT weighted_stdev( t.val, t.weight ) FROM target_vals_tbl t
WHERE t.val > 0;


I thought I'd like to write a C function (or more properly a set of two
C functions) into the server side to handle this, and then declare it
as an aggregate using CREATE AGGREGATE.  However, aggregate functions
appear to want just a single argument, so I feel like either I am on
the wrong track, or I have run into a limitation of postgresql.

What should I be doing here?  Is there a way to do this with array
functions instead?



  - Brian K. Boonstra


В списке pgsql-general по дате отправления:

Предыдущее
От: David Mitchell
Дата:
Сообщение: Re: Function to get hostname
Следующее
От: Tom Lane
Дата:
Сообщение: Re: determining supported timezones