Probably with subqueries. select (select sum(...) from. ..) as mysum, otherfield, otherfield...
http://zerp.ly/rochacbruno Em 06/08/2011 20:02, "Massimo Di Pierro" <massimo.dipie...@gmail.com> escreveu: > How would you do it in SQL? I do not know. > > On Aug 6, 5:54 pm, Tim Korb <jtk...@gmail.com> wrote: >> I have a table ("log") of points awarded to students for various activities. >> I want to produce a summary of total points per student. This query >> works... >> >> db().select(db.auth_user.ALL, db.log.points.sum(), >> left=db.log.on(db.auth_user.id == db.log.user), groupby=db.auth_user.id) >> >> but does not include students with no entries in the log table. I'd like >> them to have a point total of 0. I suspect the problem is with >> db.log.points.sum() failing on null values, but I don't know how to include >> them. >> >> Suggestions?