On Sep 11, 5:03 pm, Conor <conor.edward.da...@gmail.com> wrote:
> I believe what you want is:
> q = session.query(Option, func.count())
> q = q.outerjoin((option_senators, option_senators.c.option_id ==
> Option.id))
> q = q.group_by(Option.id)
> q = q.order_by(Option.name)
>
> which will generate this SQL:
> SELECT [...], count(*) AS count_1
> FROM options LEFT OUTER JOIN option_senators ON
> option_senators.option_id = options.id GROUP BY options.id ORDER BY
> options.name
Thank you, I was not understanding well.
:-) Works great
> Note that query method (such as outerjoin and order_by) do not modify
> the query: they return a modified copy.
>
> -Conor
--~--~---------~--~----~------------~-------~--~----~
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
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---