c.panel <[EMAIL PROTECTED]> wrote:
> one example:
> Suppose I have a table with column DATE, CREDIT, DEBIT
> I want to create a new column that is the balance of account
> (ACCOUNT).
> My first approach is to index the table on dates, then starting with
> 0, then ACCOUNT = preceding ACCOUNT + CREDIT - DEBIT.
> But how can I do this in SQL with no cursor ?

update mytable set ACCOUNT = (
    select sum(CREDIT - DEBIT) from mytable t2
    where t2.DATE <= mytable.DATE
);

Igor Tandetnik 



_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to