In the book, sum of selects is described as:
Similarly, you can use the sum operator to add (sum) the values of a
specific field from a group of records. As in the case of count, the result
of a sum is retrieved via the storage object:
>>> sum = db.log.severity.sum()
>>> print db().select(sum).first()[sum]
6
But I find that I get a key error when I do this. It appears that what is
actually returned by the select() is
<Row {'_extra': {'SUM("test1t"."item")': 6L}}>
# and to print it I need to do
print results["_extra"].values()[0]
Is this a bug (presumably in DAL), a change from an obsoleted feature, or a
mis-reading on my part?
/dps
--
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].
To view this discussion on the web visit
https://groups.google.com/d/msgid/web2py/b8cfa4b4-ef87-4790-88c2-b53102cde617%40googlegroups.com.