[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

Re: Calculating a running balance



This works on Oracle8i, have not tried to code it on sqr:

        select  var_a,
                        var_b,
                        sum(var_b) OVER (order by var_a
                                                                ROWS BETWEEN
UNBOUNDED PRECEDING AND CURRENT ROW) r_total

        from table_a
        order by var_a;



> -----Original Message-----
> From: Adam Harborow [SMTP:adam.harborow@ZURICH.COM]
> Sent: February 19, 2001 9:22 AM
> To:   SQR-USERS@list.iex.net
> Subject:      Calculating a running balance
>
> Hello
>
> I am using BRIO Report builder 6, Windows NT 4.0, Oracle 7.3.4.
>
> I am trying to compile a report that takes the form similar to a bank
> account statement.  I have a starting balance and an end balance but I
> also
> have numerous transactions (debit/credit column) that occur between the
> start and end balance.  What I need to do is have a running balance (under
> the heading balance) of the different transactions eg:
>
> debit/credit       Balance
>                               100 (starting balance)
> -50                          50
>  200                       250
> 100                        350
> -150                       200
>                                200 (end balance)
>
> Basically I have the debit/credit data and the start/end balance.  I just
> need to create a running total balance.  I need a good starting point
> hence
> the lack of any code.
>
> Thanks in advance
>
> Adam