You cannot select fields that are not in group_by. Every field that appears in SELECT must be in group_by. You are selecting db.weekly_data.ALL This doesn't work in any database and never should :)
You can use select(..., distinct=db.weekly_data.supplier_code) but this works ONLY in postgres. Marin On Wed, Aug 7, 2013 at 12:50 PM, Simon Carr <simonjc...@gmail.com> wrote: > Hi, > > in the docs it uses this code as an example. > > for row in db().select( > > db.person.ALL, > orderby=db.person.name, groupby=db.person.name): > > print row.name > Alex > Bob > Carl > > > When I run this code it fails. > > rsSuppliers = db().select( > db.weekly_data.ALL, > orderby=db.weekly_data.supplier_name, groupby=db.weekly_data. > supplier_code) > > I get this error > gluon.contrib.pg8000.errors.ProgrammingError: ('ERROR', '42803', 'column " > weekly_data.id" must appear in the GROUP BY clause or be used in an > aggregate function') > > I think this issue is related specifically to postgres. How do I group by > supplier_code and get the first supplier_name? > > -- > > --- > You received this message because you are subscribed to the Google Groups > "web2py-users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to web2py+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.