defining a table like that
db.define_table('power_curve',
Field('site', db.site, notnull=True, requires = IS_IN_DB(db,
'site.id', '%(name)s')),
Field('file_name', 'upload', uploadfield=True, notnull=True,
required=True),
Field('validity', 'date', default=datetime.date(1970, 1, 1),
requires=IS_EMPTY_OR(IS_DATE(format='%d/%m/%Y'))
)
how can I select for each site id the last file name inserted?
I tryied this two query but they give the same result and they returns
the first file name in each case:
db(db.power_curve).select(db.power_curve.site
db.power_curve.file_name,
db.power_curve.validity,
groupby=db.power_curve.site,
orderby=db.power_curve.site|~db.power_curve.start)
db(db.power_curve).select(db.power_curve.site
db.power_curve.file_name,
db.power_curve.validity,
groupby=db.power_curve.site,
orderby=db.power_curve.site|db.power_curve.start)
thank you
Manuele