I think this should do it:

r = db(db.pledge.pledgedrive==pledgedrive_id).select
(db.pledge.amount.sum())
total=r[0]._extra[db.pledge.amount.sum()]

It will not work on GAE.

On Dec 4, 10:58 am, johntynan <[email protected]> wrote:
> I have a question about finding the sum of a specific field across the
> results of an entire query
>
> While this statement will return the total number (len) of records
> returned in a query:
> pledgedrive_total_pledges = len(db
> (db.pledge.pledgedrive==pledgedrive_id).select())
>
> I would like to get the total dollars (sum) of the "amount" field that
> each of these records contains.
>
> Thank you for your help.
>
> JT
>
> P.S. As an extra bonus, I am most pleased to discover the jquery ajax/
> load script.  I may be saying goodbye to framesets for good:
>
> http://code.google.com/p/pledgedrivetracker/source/browse/pledgedrive...

--

You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.


Reply via email to