It doesn't look like you applied Massimo's solution. You're calling 
select() all by itself (not as a method of a Set object) -- doesn't that 
raise an error (there's no function called 'select' in web2py)? The sum 
should be applied in the initial query, not on the returned rows after the 
query.

Anthony

On Sunday, December 4, 2011 9:33:42 PM UTC-5, Rick wrote:
>
> 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....@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...@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