On 10 Apr, 15:54, Mike Conley <mconl...@gmail.com> wrote: > This will teach me to run a test it first, I don't think this is exactly > right, but it should be close.
That's ok all the same, thanks for taking the time for posting :) Anyway my current implementation via Query API is sub = s.query(C.d_id, func.max(C.value).label("v")).group_by (C.d_id).subquery() sub2 = s.query(C).join((sub, and_(C.d_id==sub.c.d_id, C.value==sub.c.v))).subquery() q = s.query(D, sub2.c.id).outerjoin(sub2) so the result is instances of D along the (eventually) related C.id.. Now let's see if I can fetch complete instances of C instead of just the id X-) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---