There is no easy way but I just made a commit that fixes your problem. If
you use trunk or wait for a next web2py version (within days) and you can
do:
def stck_issue_manage():
#form = SQLFORM.smartgrid(db.t_stck_issue,onupdate=auth.archive)
grid = SQLFORM.grid(db.t_stck_issue)
if gr
You raise a good point. If the calculations are done database side
then I suppose it is worth the difficulty in syntax.
I just wish the syntax was more natural.
-Thadeus
On Tue, Mar 9, 2010 at 9:54 PM, mdipierro wrote:
> I disagree. In the case you are proposing, the computation would be
>
I disagree. In the case you are proposing, the computation would be
done web2py site since you are fetching all rows.
In the current implementation you can do
s=(db.some_table.amount.sum()
+db.some_table.amount.min())*(db.some_table.amount.max()+3)
row = db(...).select(s).first()
answer = row[s]
Ah, this makes more sense now.
On Mar 9, 9:03 pm, mdipierro wrote:
> s=db.some_table.amount.sum()
> row = db(...).select(s).first()
> answer = row[s]
>
> On Mar 9, 8:23 pm, Thadeus Burgess wrote:
>
> > Is it just me or is this archaic?
>
> > -Thadeus
>
> > On Tue, Mar 9, 2010 at 6:48 PM, Russell
Still doesn't seem natural.
db(...).select().sum(db.table.field) seems much more natural.
rows = db(db.table.id > 0).select(orderby=~db.table.datetimestamp)
total_hours = rows.sum(db.table.hours_worked)
avg_hours = rows.avg(db.table.hours_worked)
Would the actual implementation of this be d
s=db.some_table.amount.sum()
row = db(...).select(s).first()
answer = row[s]
On Mar 9, 8:23 pm, Thadeus Burgess wrote:
> Is it just me or is this archaic?
>
> -Thadeus
>
> On Tue, Mar 9, 2010 at 6:48 PM, Russell wrote:
> > The number is stored in a dictionary called '_extra'. The top part of
>
It's not just you.
On Mar 9, 8:23 pm, Thadeus Burgess wrote:
> Is it just me or is this archaic?
>
> -Thadeus
>
> On Tue, Mar 9, 2010 at 6:48 PM, Russell wrote:
> > The number is stored in a dictionary called '_extra'. The top part of
> > what you are getting is the dictionary key. Do somethin
Is it just me or is this archaic?
-Thadeus
On Tue, Mar 9, 2010 at 6:48 PM, Russell wrote:
> The number is stored in a dictionary called '_extra'. The top part of
> what you are getting is the dictionary key. Do something like this to
> get just the number...
>
> row = db(...).select(db.som
The number is stored in a dictionary called '_extra'. The top part of
what you are getting is the dictionary key. Do something like this to
get just the number...
row = db(...).select(db.some_table.amount.sum())[0]
answer = row.'_extra['SUM(some_table.amount) ']
See pg 169 of the book.
On Mar
rows=db(...).select(db.some_table.amount.sum())
print rows.first()[db.some_table.amount.sum()]
On Mar 9, 6:23 pm, minh wrote:
> I couldn't find much documentation on sum() and I'm not sure how to
> use it.
>
> If I have something like
>
> define_table('some_table',
> Field('amount', 'integer')
10 matches
Mail list logo