Re: (P)SQL for a sum with constraints

Поиск
Список
Период
Сортировка
От hubert depesz lubaczewski
Тема Re: (P)SQL for a sum with constraints
Дата
Msg-id 20090415104709.GA2704@depesz.com
обсуждение исходный текст
Ответ на (P)SQL for a sum with constraints  (Shug Boabby <shug.boabby@gmail.com>)
Список pgsql-general
On Wed, Apr 15, 2009 at 11:09:49AM +0100, Shug Boabby wrote:
> Anyone have any ideas how to do this? I'm able to do it
> programmatically, but it's slow. Optimally I'd like to be able to do
> this in the DB. As you can see, it's a little trickier that the usual
> aggregate function with a GROUP BY and HAVING.

this is called cumulative sum, and can be done quite easily.

check this blogpost (but also its comments! - the c function is not
necessary!)
http://www.depesz.com/index.php/2007/08/17/rownum-anyone-cumulative-sum-in-one-query/

depesz

--
Linkedin: http://www.linkedin.com/in/depesz  /  blog: http://www.depesz.com/
jid/gtalk: depesz@depesz.com / aim:depeszhdl / skype:depesz_hdl / gg:6749007

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

Предыдущее
От: Shug Boabby
Дата:
Сообщение: (P)SQL for a sum with constraints
Следующее
От: Ow Mun Heng
Дата:
Сообщение: pg_reorg -> Anyone has any experience with it?