I think you want:

booked = db.booking.seats.sum().coalesce_zero()

On Sunday, 10 February 2013 02:53:40 UTC-6, Calycé wrote:
>
> Hi all,
>
> Given a query like the following one:
> booked = db.booking.seats.sum()
> db(db.schedule.training==db.training.id).select(db.schedule.training_date,db
> .training.short_title, db.schedule.seats, db.booking.seats.sum(), groupby
> =(db.schedule.training_date,db.training.short_title,db.schedule.seats),left
> =db.booking.on(db.schedule.id==db.booking.training_date))
>
> I'm retrieving the records I'm looking for except that for some of them I 
> have no results in the summed column. These are for the records where there 
> is no child record in the left table (booking).
> Is there a way to tell sum() to return 0 instead of None ?
>
> Thanks for your help
>

-- 

--- 
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/groups/opt_out.


Reply via email to