Re: [GENERAL] (P)SQL for a sum with constraints

2009-04-17 Thread Shug Boabby
, 15 Apr 2009 15:32:42 +0100, Shug Boabby wrote: 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

Re: [GENERAL] (P)SQL for a sum with constraints

2009-04-17 Thread Shug Boabby
Oh... and also, A, B, C are in the same table. 2009/4/17 Shug Boabby shug.boa...@gmail.com: Life sure would be easier if that were the case Michal, but no... that is not the case here. The sum is not a simple sum, it is a sum of all elements having a lower or equal A and the same C

Re: [GENERAL] (P)SQL for a sum with constraints

2009-04-17 Thread Shug Boabby
Michal... I must apologise, your suggestion worked a treat!!! I never realised it was possible to do a join on a table to itself before! 2009/4/15 Michal Politowski mpol...@meep.pl: On Wed, 15 Apr 2009 15:32:42 +0100, Shug Boabby wrote: I simplified my problem a little too much and now I'm

[GENERAL] (P)SQL for a sum with constraints

2009-04-15 Thread Shug Boabby
Hello all, I have a table with 2 bigint columns, let's call them A and B. I need a query that will allow me to return A alongside the sum of Bs from rows where A is less than or equal to this row's A. It is best described with some example data, consider the following: A B 1 0 2 1 3 0 4 2 5 1 I

Re: [GENERAL] (P)SQL for a sum with constraints

2009-04-15 Thread Shug Boabby
+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 -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http