[web2py] Re: LEFT JOIN a table to a SUM query

2010-07-23 Thread mwolfe02
That seems to work for this simple example. The actual query I'm trying to write is much more involved, but I'll see if I can apply the concept to my specific problem. You have certainly gotten me a step closer to a solution. Thanks so much for your help. On Jul 23, 3:22 pm, "mr.freeze" wrote:

[web2py] Re: LEFT JOIN a table to a SUM query

2010-07-23 Thread mr.freeze
Does this work? count = db.dog.id.count() rows=db().select(db.person.name, count, groupby=db.person.id, left=db.dog.on(db.person.id==db.dog.owner)) On Jul 23, 2:08 pm, mwolfe02 wrote: > The example under Grouping and Counting returns: > > Alex 2 > Bob  1 > > In other words, it performs an INNER J

[web2py] Re: LEFT JOIN a table to a SUM query

2010-07-23 Thread mwolfe02
The example under Grouping and Counting returns: Alex 2 Bob 1 In other words, it performs an INNER JOIN not an OUTER JOIN. This is a critical difference. In this simple example we don't get a row of information for 'Carl' because he owns no dogs. It may not be a big deal for such a simple, co

[web2py] Re: LEFT JOIN a table to a SUM query

2010-07-23 Thread mr.freeze
Doesn't the example under Grouping and Counting do what you want? On Jul 23, 1:41 pm, Michael Wolfe wrote: > Expanding on the LEFT OUTER JOIN example from > here:http://web2py.com/book/default/section/6/6 > > How would I build a query using the DAL that would return the number > of dogs each own