use this docs to shed some light ^_^

http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#sum--avg--min--max-and-len

On Wednesday, May 28, 2014 10:45:32 PM UTC+2, Floyd Noel wrote:
>
> Hello all,
>
> New web2py user here. I'm trying to translate the following query to work 
> in the DAL:
>
> SELECT items.description, sum(quantity) FROM orders.items GROUP BY 
> description;
>
> This gives me the items together with the quantity totals for each type of 
> item. I'm having trouble getting this to work in web2py however.
>
> I've tried this:
>
>     items = db.t_items
>     desc = items.f_description
>     qty = items.f_quantity
>     count_view = db().select(desc, qty.sum(), groupby=desc).as_list()
>
> Which doesn't work. If I remove the .sum(), I just get one entries' 
> quantity. How can I make this work? TIA
>
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to