Re: complex custom aggregate function

Поиск
Список
Период
Сортировка
От Gregory Stark
Тема Re: complex custom aggregate function
Дата
Msg-id 87pri5m4i0.fsf@oxford.xeocode.com
обсуждение исходный текст
Ответ на complex custom aggregate function  (Scara Maccai <m_lists@yahoo.it>)
Ответы Re: complex custom aggregate function
Список pgsql-general
Scara Maccai <m_lists@yahoo.it> writes:

> It would be very easy if the input to the custom aggregate function was
> ordered (because I would keep 4 internal counters), but I guess there's
> no way of "forcing" the ordering of the input to the function, right?

You can with a subquery. Something like

 SELECT agg(foo) from (SELECT foo ORDER BY bar)

However that will produce one record per grouping. From what I read of your
description you want to produce one record per input record. There isn't any
efficient way to do that in current Postgres releases -- you would have to
have a subquery which executed for every record and retrieved the set of data
to aggregate.

8.4 Will have OLAP Window functions which can implement things like moving
averages.

--
  Gregory Stark
  EnterpriseDB          http://www.enterprisedb.com
  Get trained by Bruce Momjian - ask me about EnterpriseDB's PostgreSQL training!

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

Предыдущее
От: Igor Katson
Дата:
Сообщение: Plproxy functions inside transactions and Pl/pgsql exception handling
Следующее
От: Reg Me Please
Дата:
Сообщение: PGSQL and Javascript