Re: (P)SQL for a sum with constraints

Поиск
Список
Период
Сортировка
От Shug Boabby
Тема Re: (P)SQL for a sum with constraints
Дата
Msg-id 9508491d0904150732j2df4d05ie67057eb2501209b@mail.gmail.com
обсуждение исходный текст
Ответ на (P)SQL for a sum with constraints  (Shug Boabby <shug.boabby@gmail.com>)
Ответы Re: (P)SQL for a sum with constraints  (Michal Politowski <mpol+pg@meep.pl>)
Список pgsql-general
I simplified my problem a little too much and now I'm stuck trying to
use cumulative_sum(). My schema is not only A, B but also has a C

A B C
1 0 1
2 1 1
3 0 1
4 2 1
5 1 1
1 0 2
2 1 2
3 0 2
4 2 2
5 1 2

and I want to be able to do the cumulative sum only when C is the same. E.g.

A funkySumB C
1 0 1
2 1 1
3 1 1
4 3 1
5 4 1
1 0 2
2 1 2
3 1 2
4 3 2
5 4 2

Also... could you please explain why the syntax requires the
"user_id::text" to be passed to cumulative sum? I'm confused why the
"::text" part is there.

2009/4/15 hubert depesz lubaczewski <depesz@depesz.com>:
> On Wed, Apr 15, 2009 at 01:37:45PM +0100, Shug Boabby wrote:
>> Thanks, I'll look at this... I still have to define cumulative_sum
>> though, right?
>
> yes. it's just the c function that is obsolete.
>
> Best regards,
>
> depesz

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

Предыдущее
От: Chander Ganesan
Дата:
Сообщение: Re: backup getting larger and larger
Следующее
От: Tom Lane
Дата:
Сообщение: Re: a question about postgresql server connection