I used the following example:

http://web2py.com/book/default/chapter/06?search=sum#sum,-min,-max-and-len


I created your operations table, but not the budget table:

>>> sum = db.operations.amount.sum().coalesce_zero()
>>> monthly_amount = db((db.operations.date.year()==current_year) & 

...                     (db.operations.date.month()==current_month)
...                    ).select(sum).first()[sum]
>>> monthly_amount
45.0


Reply via email to