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/            p...@phdru.name
           Programmers don't die, they just GOSUB without RETURN.

------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and, 
should the need arise, upgrade to a full multi-node Oracle RAC database 
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to