[sqlalchemy] Re: SQL newbie question: How to select the last message for each user

2007-05-16 Thread Noam Raphael
On 16/05/07, Glauco <[EMAIL PROTECTED]> wrote: > > are you searhing for ? > > select max( changeTime ) from OrderDiscount group by orderID ; ? > > i don't understand well what you are searching for > Thanks to all of you! I actually needed the last message itself - more than just its date. Tha

[sqlalchemy] Re: SQL newbie question: How to select the last message for each user

2007-05-16 Thread Glauco
are you searhing for ? select max( changeTime ) from OrderDiscount group by orderID ; ? i don't understand well what you are searching for Glauco --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "sqlalchemy" g

[sqlalchemy] Re: SQL newbie question: How to select the last message for each user

2007-05-16 Thread Barry Hart
I wrote a similar query in SQLObject - in one query it retrieves the most recent discount for every order in the list orderIDs. The code is below; it should be pretty easy to translate to SQLAlchemy. The technique is to use nested SQL queries - the innermost query uses MAX to determine the most

[sqlalchemy] Re: SQL newbie question: How to select the last message for each user

2007-05-16 Thread Glauco
YourMessageMapper.select_by( tbl['users'].c.id == $$$, order_by= [desc(tbl[messages'].c.data)], limit=1) this is your last message for $$$ person Glauco --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "sqlalch