Yes, the "max" solution was originally for a different problem that only 
needed the single max value and involved only one query. In this case, the 
orderby/limitby solution is the way to go.

Anthony

On Wednesday, September 12, 2012 2:36:37 PM UTC-4, Niphlod wrote:
>
> ps: methods are NOT equivalent. They are if you have "continous" ids. 
> But, e.g., you remove some rows. You end up with 
> 1,2,3,4,5,6,7,8,9,10,11,13,15,17,20.
> Second method (i.e. calc max and go back by ten) leaves you with 
> 20,17,15,13,11,10 (and takes two queries)
> First method (i.e. orderby + limitby) correctly returns 
> 20,17,15,13,11,10,9,8,7,6.
>
> On Wednesday, September 12, 2012 7:09:39 PM UTC+2, Anthony wrote:
>>
>> On Wednesday, September 12, 2012 12:35:41 PM UTC-4, Massimo Di Pierro 
>> wrote:
>>>
>>> Instead of this
>>>
>>> maxID=db(db.node).select(db.node.id.max()).first()['MAX(node.id)']
>>>
>>> I would do
>>>
>>> maxID=db(db.node).select(db.node.id.max()).first()[db.node.id.max()]
>>>
>>
>> Well, that's what I really recommended: 
>> https://groups.google.com/d/msg/web2py/VY71mF2cl-4/oNE00OduXQ0J. :-)
>>  
>>
>

-- 



Reply via email to