I tried to apply the solution to my code, but it still doesn't work.
Here is the code:

        prerecords = db().select(db.day.ALL, orderby=db.day.thedate)    for
prerecord in prerecords:                if prerecord.theauth==auth.user_id:     
                if
session.adate==prerecord.thedate:                               
records.append(prerecord)       rows =
select(records.thedate,records.value.sum(),orderby=records.thedate) 
for row in rows:                print row.records.thedate, 
row(records.value.sum())
On Dec 5, 3:04 am, Massimo Di Pierro <massimo.dipie...@gmail.com>
wrote:
> 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!

Reply via email to