Il 01/05/14 10:16, Manuele Pesenti ha scritto:
> ok, I tried without success...
> with the solution I found patching the dal source code adding the
> array_agg expression method as described I defined this query.
> Can you help me to get the same using expressions?
well... I solved in this way at the moment, in order not to patch web2py
source code.
Still stand the question how to get only one value in column
data_manager_id.

max_severity = db.r_monitoring.severity.coalesce_zero().max()
data_manager_ids = 'array_agg(p_data_manager.id) as data_manager_id'
status_infos = 'array_agg(r_monitoring.status_info) as status_info'

view_definition = db(
    (db.r_monitoring.data_manager_id==db.p_data_manager.id) & \
    (db.p_data_manager.location_id==db.p_installation.id))._select(
        db.p_installation.id,
        db.p_installation.name,
        db.p_installation.the_geom,
        db.p_installation.customer,
        max_severity.with_alias('severity'),
        data_manager_ids,
        status_infos,
        groupby = db.p_installation.id,
        orderby = ~max_severity
)

Thank you
Cheers

    Manuele

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to