rows = db(db.test).select(limitby=(0,2))
rows[1].update_record(t2 = rows[1].t1-rows[0].t1)

or if you need it for all records:

row0 = db(db.test).select(limitby=(0,1)).first()
db(db.test).update(t2 = db.test.t1-row0.t1)



On Sunday, 23 June 2013 01:42:30 UTC-5, Tribo Eila wrote:
>
> Hi, 
>
> Supposed a model:
>
> db.define_table('test',
>     Field('t1', 'integer'),
>     Field('t2', 'integer'),
>     )
>
> How to find the difference in db.test.t1 (ex: db.test.t2(row2) = 
> db.test.t1(row2) - db.test.t1(row1)) and store the result in db.test.t2.
>
> What approach should i used? Thanks.
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to