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. > --