Em 12/9/2012 15:28, K Z escreveu:
> Hello,
>
>
> Is there a trick to have this?
>
> CREATE TABLE BANK_ACCOUNT
> (
> ID INTEGER NOT NULL,
>    OCCURRENCE TIMESTAMP,
>    DESCRIPTION VARCHAR(100),
>    AMOUNT DECIMAL(10,2) NOT NULL
> CONSTRAINT PK_
> BANK_ACCOUNT _1 PRIMARY KEY (ID)
> );
>
>
>
> CREATE VIEW  BANK_ACCOUNT_STATEMENT (ID,
> OCCURRENCE ,
> DESCRIPTION ,  AMOUNT, BALANCE)
> AS
>
> SELECT r.*,  (Calculated Field)
>   as BALANCE
> FROM
> BANK_ACCOUNT r
> order by r.OCCURRENCE
>   desc
> ;
>
>
> Calculated Field is the previous record balance plus the current record field 
> AMOUNT. If there is no previous record, then is the current record field 
> AMOUNT.
>
> For example:
> ID  DESCRIPTION  AMOUNT  BALANCE
> 1  Deposit                  10               10
> 2  Check                    -5                5
> 3  Check                    -10              -5
> 4  Credit transfer        50                45
>
> Thank you in advance for your support.
>
>


I would implement it on the client side...

It depends on the date range selected, the order of the records stored, 
and so on...

IMHO it's a dynamic thing that must be calculated on the fly.

Reply via email to