See http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Grouping-and-counting.
On Friday, December 28, 2018 at 6:46:25 AM UTC-5, Jonsubs wrote: > > Hi all, > I'd like to know how to access the ".count()" result of a query from a > view. > > I have the following query in the controller: > > rows = > db(db.probdata).select(db.probdata.game,db.probdata.game.count(),groupby=db.probdata.game) > > And would like to show both the 'game' field and the number of entries for > each game. I tried the code below, but it crashes: > > <ul> > {{for r in rows:}} > > <li>{{=A(r.probdata.game,_href=URL('list_problems_by_game',args=r.probdata.game))}} > > {{=r.probdata.game.count()}}</li> > {{pass}} > </ul> > > How should I access the result of the ".count()" part of the query from > the view? > Thanks, Jon. > -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.