If you just want rows back, you can pass raw SQL using dal. I personally haven't done what you are doing, but the DAL parses the query and turns it into sql appropriate for your adapter. grouping happens on the server.
I very much doubt this includes translating python functions into the functions of your database backend but apparently simple arithmetic functions work. TLDR: look at executesql in the book. On Wednesday, 5 February 2014 00:45:57 UTC+11, art...@xs4all.nl wrote: > > Consider the following query > > rows = db(db.table).select(x,y groupby = x) > > If x and y are table fields this obviously works. > > Now consider > > group = x/100 > > rows = db(db.table).select(group,y, groupby = group) > > This also works nicely and will group into groups for each x with a value > of x divided by 100, but is of little use. > > However, the following fails: > > group = math.floor(x/100) and throws the exception function doesn't have > attribute type > > The intent is to group numeric values into ranges, so I am trying to > implement a slightly more complex function which returns a range > indicator, perhaps as a string (e.g. "100-200"), but in order to get that > working first the simple case of using the result of a function needs to be > solved. > > In plain SQL calling a function is an option, perhaps it is a limitation > of the DAL > > thnx > Arthur > -- 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/groups/opt_out.