[sqlalchemy] Re: distinct (or group by) with max in sqlalchemy - how to?

2009-09-06 Thread Mike Conley
See the documentation at http://www.sqlalchemy.org/docs/05/sqlexpression.html#functions Something like this Using ORM mapped classes session.query(Tabl.name, func.max(Tabl.cnt)).group_by(Tabl.name).all() or SQL expression language

[sqlalchemy] Help convert my SQL query to SQLAlchemy

2009-09-06 Thread Richie Ward
I would like to convert this query to SQLAlchemy: SELECT revision_id, modulename, content FROM content WHERE revision_id IN ( SELECT MAX(revision_id) FROM content c GROUP BY modulename ) AND content != '' ORDER BY modulename with this table: CREATE TABLE content (