On Sep 3, 6:15 pm, Mike Conley <mconl...@gmail.com> wrote:
> On Thu, Sep 3, 2009 at 8:05 AM, Noufal <nou...@gmail.com> wrote:
>
> >    stmt = session.query(Order.table.c.client_id,func.max
> > (Order.table.c.date).label('latest_order')).group_by
> > (Order.table.c.date).subquery()
>
> I think your group_by needs to be   Order.table.c.client_id  to get latest
> order per client

Ah. Select the one with the highest date when they're bunched together
by client_id. Makes sense. It works too.

Thanks Mike.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to