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 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 'cause rowid will be more
> precise,
> whereas dates could be duplicated and may not give desired results.  This
> assumes records are always inserted in chronological order.
> 
> HTH,
> 
> Sam
> 
> 
> -----------------------------------------------------------------
> We're Hiring! Seeking passionate Flex, C#, or C++ (RTSP, H264) developer
> in
> the Washington D.C. Contact [EMAIL PROTECTED]
> 
> On Thu, Jul 3, 2008 at 12:03 PM, c.panel <[EMAIL PROTECTED]> wrote:
> 
>>
>> 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 with 0,
>> then
>> ACCOUNT = preceding ACCOUNT + CREDIT - DEBIT.
>> But how can I do this in SQL with no cursor ?
>>
>> I'm afraid of complexity of SQL for simple problems.
>> What do you think of this ?
>>
>> Does SQL is reserved for one sort of database management ?
>>
>>
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Simple-problem---tp18262458p18263589.html
Sent from the SQLite mailing list archive at Nabble.com.

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

Reply via email to