On Jul 24, 7:19 pm, Michael Bayer mike...@zzzcomputing.com wrote:
[..]
finding a list of objects and the most recent/highest/somethingest
related item requires joining to a subquery, where the subquery selects
the func.max(desiredfield) and GROUP BY's the columns that relate the rows
to the
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
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
It sounds like you need a subquery that finds last order then construct a
query joining clients and orders to the subquery.
http://www.sqlalchemy.org/docs/05/ormtutorial.html?highlight=subquery#using-subqueries
Something like this:
class Client(Base):
__tablename__ = 'client'
id =
Noufal wrote:
Hello everyone,
I've been using sqlalchemy with elixir for a legacy project for a
while now and recently needed to write some more than trivial queries.
I have the default elixir generated mappers but using only them forces
me to do some data processing in my app rather