Re: [web2py] How do I get last row for each type from table?

2013-01-07 Thread Hans Cr
Thanks, indeed this was the way. This works great: tb = db.value values = db((tb.gid == 'something')).select(groupby=tb.value, orderby=~tb.updated) On Monday, January 7, 2013 1:28:39 PM UTC+1, viniciusban wrote: > > Try using groupby clause. > > On Mon, Jan 7,

[web2py] How do I get last row for each type from table?

2013-01-07 Thread Hans Cr
I want my controller to return the last ('updated') row for each 'sid', given a specified 'gid'. 'sid' is multiple times in the table, but I want to have the last row. Can anyone help me? Thanks a lot in advance! Hans db.define_table('value', Field('gid', 'string'), Field('sid', 'stri

[web2py] Re: How do I get last n rows from table?

2013-01-07 Thread Hans Cr
Thanks! Works great! On Monday, January 7, 2013 12:33:19 PM UTC+1, Niphlod wrote: > > tb = db.value > db((tb.gid == 'something') & (tb.sid == 'othersomething')).select(orderby > =~tb.updated, limitby=(0, 10)) > > will give you the last 10 > > On Mo

[web2py] How do I get last n rows from table?

2013-01-07 Thread Hans Cr
I want my controller to return the last ('updated') n rows given de definition below given a certain 'gid' and 'sid'. Can anyone help me? Thanks a lot in advance! Hans db.define_table('value', Field('gid', 'string'), Field('sid', 'string'), Field('value', 'integer', required=True),