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, 2013 at 10:19 AM, Hans Cr <[email protected]<javascript:>> 
> wrote: 
> > 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', 'string'), 
> >     Field('value', 'integer', required=True), 
> >     Field('updated', 'datetime', default=request.now, writable=False, 
> > readable=False), 
> >     format = '%(value)s') 
> > 
> > -- 
> > 
> > 
> > 
>

-- 



Reply via email to