I'm trying to transliterate this sql into web2py:
select g.name, p.status, count(*)
from garden g
join plot p on g.id = p.garden_id
group by g.name, p.status
order by g.name;
Given this model:
db.define_table('garden',
Field('name',requires=[IS_NOT_EMPTY()]),
Field('status'))
db.define_table('plot',
Field('garden_id','reference garden'),
Field('name',requires=[IS_NOT_EMPTY()]),
Field('status'))
I can't see from the doco how to add the count(*) field to the select list:
grid=SQLFORM.grid(db.garden,
fields=[db.garden.name,db.plot.status],
headers={'garden.name':'Garden', 'plot.status':'Plot(s) Status'},
left=db.garden.on(db.garden.id==db.plot.garden_id),
orderby=db.garden.name|db.plot.name,
groupby=db.garden.name|db.plot.status)
Thanks!
Don
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
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.