ok, i got it sorted.  discovered the 'alias' method, and also realized
that t in tags consists of tuples of Tag object and integer (for the
count), not simply Tag objects with a new attribute for the count.
thanks again, i'm on my way now..  for the sake of documentation, my
new code is:

s = select([ObjectTag.c.tag_id, func.count('*').label('obj_count')]).\
        where(ObjectTag.c.object_type_id == 2).\
        group_by(ObjectTag.c.tag_id).\
        order_by(desc(func.count('*'))).\
        limit(35).alias('top_tags')

tags = session.query(Tag).add_column(s.c.obj_count).\
        select_from(Tag.table.join(s, Tag.id == s.c.tag_id)).\
        order_by(Tag.name)

for t in tags:
        print t[0].name + ' has ' + str(t[1]) + ' articles'

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to