My bad. It should be

t.created_on.max()

On Saturday, 18 August 2012 04:26:37 UTC-5, mcamel wrote:
>
> Hi,
>
> Massimo, i really like your framework. Thank you very much for your 
> dedication.
>
> I'm newbie and don't want to bother but... i think some details are 
> missing in the manual so that we can build this kind of selects by our own, 
> or even understand the query below.
>
> Are there references to 'created_on' missing?. I mean, i expected your 3rd 
> line to be:
>     max_created_on = t.max(created_on)
>
> and then use one of the two sides of the expression on the 5th line:
>     db(query).select(t.device_id,t.sensor_id,t.max(created_on),...
> or
>     db(query).select(t.device_id,t.sensor_id,max_created_on,...
>
> also 4th line souldn't be...?:
>     query = Expression(db,"date_sub(now(), interval interval_time minute) 
> > created_on")
>
>
> Hope not to bother.
> Many thanks.
>
>
> BTW, i offer myself to help to improve some parts of the manual from the 
> point of view of someone who is yet learning.
>
> Best regards,
>     mcamel.
>
>
> On Friday, August 17, 2012 4:26:39 PM UTC+2, Massimo Di Pierro wrote:
>>
>> You can try this:
>>
>> from gluon.dal import Expression
>> t = db.abc_tbl
>> max_created_on = t.max()
>> query = Expression(db,"date_sub(now(), interval interval_time minute)")
>>
>> db(query).select(t.device_id,t.sensor_id,t.max(),group_by=t.device_id|t.sensor_id)
>>
>> On Thursday, 16 August 2012 23:01:44 UTC-5, Amit wrote:
>>>
>>> I have written one sql query:
>>>
>>> select device_id, sensor_id, max(created_on) from test.abc_tbl where 
>>> date_sub(now(), interval interval_time minute) > created_on group by 
>>> device_id, sensor_id;
>>
>>
>>> How to write it in web2py?
>>>
>>> Please help me to do the same.
>>>
>>> Thanks.
>>>
>>

-- 



Reply via email to