Hi,
i know is a little bit tricky but i need to know the credit of a client after each invoice.
so if sum(invoice_val-previous_credit) >0 then the credit is 0 else credit is previous_credit-invoice_val.
As you can see to dermine the credit value of the current row it is needed to check the same value of the previous row.Is this possible in some way?
EX.
so the situation in the table is the following:
ID_CLIENT ID_invoice invoice_VAL
8.789 220.227 120,47
8.789 238.342 109,76
8.789 246.388 121,69
8.789 258.163 137,45
8.789 268.969 138,67
8.789 295.455 145,16
8.789 311.395 138,92
8.789 327.104 138,96
8.789 340.793 -335,18
8.789 375.451 129,14
8.789 386.650 125,57
8.789 398.606 124,18
8.789 428.166 31,66
8.789 435.844 25,93
8.789 447.639 34,32
8.789 462.137 -43,64
8.789 475.613 -110,39
8.789 485.022 92,29
8.789 495.807 91,67
i need something like this:
ID_CLIENT ID_invoice invoice_VAL credit
8.789 220.227 120,47 0,00
8.789 238.342 109,76 0,00
8.789 246.388 121,69 0,00
8.789 258.163 137,45 0,00
8.789 268.969 138,67 0,00
8.789 295.455 145,16 0,00
8.789 311.395 138,92 0,00
8.789 327.104 138,96 0,00
8.789 340.793 -335,18 335,18
8.789 375.451 129,14 206,04
8.789 386.650 125,57 80,47
8.789 398.606 124,18 0,00
8.789 428.166 31,66 0,00
8.789 435.844 25,93 0,00
8.789 447.639 34,32 0,00
8.789 462.137 -43,64 43,64
8.789 475.613 -110,39 154,03
8.789 485.022 92,29 61,74
8.789 495.807 91,67 0,00
thanks very much
Edited by: 4ndr34 on Jan 28, 2010 1:38 PM