Re: [sqlite] Simple problem ?

2008-07-03 Thread c.panel
> In each row, do you want balance before that row's credit/debit has > taken place, or after? <= does the latter, < would do the former. yes, I understand. > My statement never uses any previous value of ACCOUNT field, null or > otherwise. yes of course, how stupid of me ! thanks a lot

Re: [sqlite] Simple problem ?

2008-07-03 Thread Igor Tandetnik
c.panel <[EMAIL PROTECTED]> wrote: > Good ! I've not seen like this ! > but why "where t2.DATE <= mytable.DATE" instead of where "t2.DATE < > mytable.DATE" In each row, do you want balance before that row's credit/debit has taken place, or after? <= does the latter, < would do the former. >

Re: [sqlite] Simple problem ?

2008-07-03 Thread c.panel
thank you. But I have a question : is rowid growing with dates ? I believed that rowid is the original order, not the index order (???). I'm going to look at this. Samuel Neff wrote: > > you can do it with a subquery, like > > select o.date, (select sum(credit - debit) from bank i where

Re: [sqlite] Simple problem ?

2008-07-03 Thread c.panel
Good ! I've not seen like this ! but why "where t2.DATE <= mytable.DATE" instead of where "t2.DATE < mytable.DATE" because what about if ACCOUNT soon exists with no null value and you want to update? Igor Tandetnik wrote: > > c.panel <[EMAIL PROTECTED]> wrote: >> one example: >> Suppose I have

Re: [sqlite] Simple problem ?

2008-07-03 Thread Igor Tandetnik
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 +

Re: [sqlite] Simple problem ?

2008-07-03 Thread Samuel Neff
you can do it with a subquery, like select o.date, (select sum(credit - debit) from bank i where i.rowid < o.rowid) from bank o order by rowid; but it would be _much_ more efficient to handle it in your host application as you loop through the data. Notice that I used rowid instead of date

[sqlite] Simple problem ?

2008-07-03 Thread c.panel
Hello, I'm learning SQL and have some difficulties to resolve some simple problems with SQL. 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