Re: Aggregate functions on ordered data?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Aggregate functions on ordered data?
Дата
Msg-id 14531.1056321953@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Aggregate functions on ordered data?  (Andreas Lehrbaum <andreas.lehrbaum@kabelweb.at>)
Список pgsql-general
Andreas Lehrbaum <andreas.lehrbaum@kabelweb.at> writes:
> Is it possible in _any_ way to control the order of the rows passed to an
> aggregate function?

For simple aggregation you can do

SELECT myagg(col) FROM (SELECT col FROM ... ORDER BY foo) ss;

If you wanted to group, you could try

SELECT gcol, myagg(col) FROM
  (SELECT gcol, col FROM ... ORDER BY gcol, foo) ss
GROUP BY gcol;

but this does *not* work reliably in current releases (it will work in
7.4 though).  See the archives.

            regards, tom lane

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Schemas and access
Следующее
От: Ron Johnson
Дата:
Сообщение: Re: A creepy story about dates. How to prevent it?