You should do a separate query and have the database calculate the sum for
you (rather than loading all the records from the database and doing the
calculation in Python).
Anthony
On Tuesday, July 24, 2018 at 3:08:12 PM UTC-4, sandeep patel wrote:
>
> Hello,
> I have a grid that is worked as I expected. now I want to sum all the
> values that have in "number_of_bags" Field.
> So that I have used grid.rows (*sum([int(grid.rows[i].number_of_bags) for
> i in range(len(grid.rows))])*) but this gives me sum of first 10 records
> but i want sum of all the values which is in my grid.
> How can I do that in an efficient way?
>
>
> *#Model db.py*
>
> db.define_table('whr',
> Field('id_inword'),
> Field('whr_number'),
>
> Field("customer_name",requires=IS_NOT_EMPTY(),label="Account Holder's
> Name"),
> Field("whr_holder_name",label="WHR Holder's Name"),
> Field("father_name", label="Father Name"),
> Field("phone_number",label="Phone Number"),
> Field("number_of_bags",label="Number of bags"),
> auth.signature)
>
> Best
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
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/d/optout.