If someone wanted to put arbitrary aggregates into PostgreSQL, I would suggest something akin to the "RED BRICK" API, or better yet, the ATLAS API: http://magna.cs.ucla.edu/atlas/
pgsql-general by date:
Соглашаюсь с условиями обработки персональных данных