It's a bit of an ugly trick, but I've ever done something like this before.

created_on_min = db.my_table.created_on.min().with_alias(created_on_min)
created_on_max = db.my_table.created_on.max().with_alias(created_on_max)
created_on_min.tablename = 'my_table' 
created_on_max.tablename = 'my_table'

fields = [
    db.auth_user.id,
    created_on_min,
    created_on_max
]

Does anyone know of a better way to do it?

El miércoles, 23 de diciembre de 2020 a las 23:52:06 UTC+1, Vlad escribió:

> Is there a limitation in the way SQLFORM.grid() can be used with groupby 
> in the sense that functions like min(), max(), count() can't be used? 
>
> the following gives an error: 
> fields = [db.auth_user.id, db.my_table.created_on.min(), 
> db.my_table.created_on.max()]
> grid = SQLFORM.grid(query, fields=fields, groupby= db.auth_user.id)
>
> the error is: 
> <class 'AttributeError'> 'Expression' object has no attribute 'tablename'
>   
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/171a8b1f-a9ed-4796-9481-59c5ea520e1fn%40googlegroups.com.

Reply via email to