@Anthony, This gives me an error.becouse of some values float type in the
field.

<type 'exceptions.TypeError'>('float' object is not iterable)
How can I successfully sum all the values within this solution?

Thanks

On Thu, Jul 26, 2018 at 4:09 PM Anthony <[email protected]> wrote:

> #controller.py
>>
>> grid = SQLFROM.grid(query,..,...)
>> a = grid.__dict__
>> b = sum([int(i.number_of_bags) for i in  a['dbset'].select()])
>>
>>
> This is more efficient because the database calculates the sum for you and
> you don't have to load all of the database records into the web2py process:
>
> bag_sum = db.mytable.number_of_bags.sum()
> b = db().select(bag_sum).first()[bag_sum]
>
> See
> http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#sum--avg--min--max-and-len
> .
>
> Anthony
>
> --
> 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.
>

-- 
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.

Reply via email to