I got it:

>> from sqlalchemy.sql import func

>> stmt = session.query(Prod.store_id, 
>> func.count('*').label('prod_count')).group_by(Prod.store_id).subquery()
>> obj_q = session.query(Store, stmt.c.prod_count).outerjoin(
        (stmt,
Store.id==stmt.c.store_id)).order_by(stmt.c.prod_count.desc())

Voil`a!

Cheers,
Sandor

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

Reply via email to