rows = db(...).select(db.table.date,db.table.value.sum(),groupby=db.table.date) for row in rows: print row.table.date, row(db.table.value.sum())
mind that 'date' and 'value' are not good field names. Will work with sqlite but will break with other engines. On Dec 4, 8:00 pm, Rick <sababa.sab...@gmail.com> wrote: > Hi, > I've a stack of records where records with the same date has different > values, eg: > record.date[0] = 2011-12-01 > record.value[0] = 10 > record.date[1] = 2011-12-01 > record.value[1] = 20 > record.date[3] = 2011-12-02 > record.value[3] = 10 > And now I want to summarize the values that are recorded for > respective date: > sumlist.date[0] = 2011-12-01 > sumlist.value[0] = 30 > sumlist.date[1] = 2011-12-02 > sumlist.value[1] = 10 > > I suppose I should use "filter" and "sum", but I don't know how. Any > ideas? > > Thanks in advance for help!