Re: Grouping, Aggregate, Min, Max

Поиск
Список
Период
Сортировка
От David Johnston
Тема Re: Grouping, Aggregate, Min, Max
Дата
Msg-id 1386949350894-5783318.post@n5.nabble.com
обсуждение исходный текст
Ответ на Re: Grouping, Aggregate, Min, Max  (Misa Simic <misa.simic@gmail.com>)
Список pgsql-general
Re:custom aggregate:

I'd probably try building a two dimensional array in the state transition
function.  Take the new value and check if it is adjacent to the last value
in the last bin of the current state. If so add it to that bin.  If not
create a new bin and store it there.  Requires sorted input.

You could also just store all the values encountered and at the end group
them into bins after sorting internally.  That way you just need to get the
partition right - not the order by and sub-groups.

The final output is just a call to string_agg though you would have to
unnest the array in a custom manner since unnest() flattens
multiple-dimensional arrays.  See a recent thread for specifics.

David J.




--
View this message in context: http://postgresql.1045698.n5.nabble.com/Grouping-Aggregate-Min-Max-tp5783279p5783318.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


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

Предыдущее
От: Adrian Klaver
Дата:
Сообщение: Re: invisible dependencies on a table?
Следующее
От: John R Pierce
Дата:
Сообщение: Re: design for multiple time series