Thank you! That tuple thing was a fail on my part, clearly. Doing it exactly as you describe still doesn't get things to be, for lack of a better term, correlated.
This, however, achieves what I want: session.query(Route,sq.c.max_hop).join((sq, and_(Route.hop_id==sq.c.max_hop, Route.ts==sq.c.ts,Route.startpoint==sq.c.startpoint,Route.target==sq.c.target))).all() This seems no different than the filter based approach outlined in the initial code. Is this not the point of correlated sub queries, or am I missing something? If so, how do I achieve it? Thanks again, for all the help, and for making SqlA such a great (and powerful!) product. Thanks! GL On Fri, Jul 24, 2009 at 11:59 AM, Michael Bayer<mike...@zzzcomputing.com> wrote: > > Gregg Lind wrote: >> session.query(Route.ts,Route.startpoint,Route.target,func.max(Route.hop_id).label('max_hop'))\ >> .group_by(Route.ts,Route.startpoint,Route.target).subquery() >> q = >> session.query(Route,sq.c.max_hop).join(sq,sq.c.max_hop==Route.hop_id) >> q.all() > > join takes tuples in this form: > > join((sq,sq.c.max_hop==Route.hop_id)) > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---