8 messages in com.googlegroups.sqlalchemy[sqlalchemy] Re: Maybe possibly a map...
FromSent OnAttachments
Chris Perkins10 May 2007 09:05 
Michael Bayer10 May 2007 10:53 
Chris Perkins11 May 2007 08:38 
Michael Bayer11 May 2007 10:48 
Rick Morrison11 May 2007 10:51 
Paul Johnston11 May 2007 11:39 
Rick Morrison11 May 2007 12:42 
Michael Bayer11 May 2007 15:45 
Subject:[sqlalchemy] Re: Maybe possibly a mapper bug
From:Michael Bayer (mike@zzzcomputing.com)
Date:05/11/2007 10:48:31 AM
List:com.googlegroups.sqlalchemy

On May 11, 2007, at 11:38 AM, Chris Perkins wrote:

The second is "Incorrect syntax near the keyword 'ON'" for: SELECT select_2.ver AS select_2_ver, select_2.id AS select_2_id FROM (SELECT [T].id AS id, [T].ver AS ver FROM [T] JOIN ((SELECT [T].id AS mvid, max([T].ver) AS maxver FROM [T] GROUP BY [T].id)) ON mvid = [T].id AND [T].ver = maxver) AS select_2 ORDER BY select_2.id

the problem with that one is that you are joining to a select without an alias name. set maxvers = maxvers.alias('foo') and see how that works. you can also try rewriting that query using just the onclause of the join without the JOIN keyword.

as always, the best way to do these is to write the literal SQL first, test it in your DB, then create the select() expression to match.