rows =
db().select(db.t_ticket.f_status,db.t_ticket.id.count(),groupby=db.t_ticket.f_status)
for row in rows:
print row.status, row(db.t_ticket.id.count())
On Jul 27, 4:24 pm, Kenneth Lundström <[email protected]>
wrote:
> Hello,
>
> what would be the easiest way to find out how many items there is in a
> table grouped by a field.
>
> I have a table where tickets are stored. Every ticket has an status, he
> number of statuses can change (only a reference to the t_status table).
> How do I find out how many tickets there is of every status?
>
> Is this the easiest?
>
> number_of_tickets= {}
> for status in db(db.t_status).select()
> number_of_tickets[status.id] = len(db(db.t_ticket.f_status ==
> status.id).select()))
>
> Kenneth