tags are stored as '[red][green][blue]' so you can search using like

db(db.transaction.tags.like('%[red]%')).count()

will count all the items tagged red.

Do not call your table transaction, it is a SQL keyword.

Massimo

On Oct 17, 2:36 pm, "Steve Shepherd" <[EMAIL PROTECTED]> wrote:
> Ok thats what I mean
>
> I have a question though:
>
> If you have code like:
>
> # Model
> db.definetable('transaction',
>   db.field('spendamount,'double'),
>   db.field('tags','text'))
>
> # Controller Count and Totals
> #I want some code to create an object that groups by the tags field and
> provides and total for spendamount and a count
> # ie something like db.select('sum(spendamount), count()', 'group_by tags')
> # I realise that tags is a text field but do you have any suggestions I am
> trying to get the following
>
> # example of transactions and summary output by tags
>
> # Transactions
> # spendamount     tags
> # 10                     red, blue, green
> # 33                     blue
> # 22                     blue, green
>
> # Summary
> # Tags          SumofSpendamount     CountofRecords
> # red                  10                              1
> # blue                 65                              3
> # green               32                             2
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to