It is probably useful to see the following as well: >>> sum = db.operations.amount.sum().coalesce_zero()
>>> sum
<gluon.dal.Expression object at 0x12e68d0>
>>> print sum
COALESCE(SUM(operations.amount),0)
>>> monthly_amount_first = db((db.operations.date.year()==current_year) &
... (db.operations.date.month()==current_month)
... ).select(sum).first()
>>> monthly_amount_first
<Row {'_extra': <Row {'COALESCE(SUM(operations.amount),0)': 45.0}>}>
>>> monthly_amount_first[sum]
45.0

