Group By + Count

1,362 views
Skip to first unread message

pistacchio

unread,
Jan 24, 2010, 12:22:10 PM1/24/10
to web2py-users
How to translate the following SQL query in a web2py DAL expression?
Thanks

SELECT field, count(*) FROM table GROUP BY field

pistacchio

unread,
Jan 24, 2010, 12:29:27 PM1/24/10
to web2py-users
Nevermind, i found it in the book minutes after posting :)

For those interested:
count = db.table.field.count()
result = db().select(db.table.field, count, groupby = db.table.field)

Reply all
Reply to author
Forward
0 new messages