From: Oleg B. <ph...@ph...> - 2010-12-23 22:59:30
|
On Wed, Dec 22, 2010 at 10:18:49PM -0500, Ben Timby wrote: > What is the most expedient way to do the following? > > serial = Path.selectBy().max('serial') > return Path.getOne(serial=serial) > > I would like some SQL like this: > > select * from path where serial = (select max(serial) from path); .select().max() produces a simple query SELECT MAX(). If you need a query with a subquery you need to add the subquery explicitly using sqlbuilder.Select(): serial = Path.select( Path.q.serial==Select('max(serial)', staticTables=['path'])) return serial.getOne() Oleg. -- Oleg Broytman http://phdru.name/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |