Sorry I miss a piece:

sumAuditorHours = (db.a_wlp2_distrib.LC_HOURS + db.a_wlp2_distrib.SM_HOURS
+ db.a_wlp2_distrib.LB_HOURS)
fields = [db.s_disc_names.id.with_alias('id'),
          db.s_disc_names.FULL_NAME-with_alias('full_name'),
          db.a_wlp2.CHAIR.with_alias('chair'),
          sumAuditorHours.with_alias('auditor_hours'),
         ]
subjects = db((db.a_groups.id == group) & (db.a_wlp2_distrib.MODULE ==
module) & (db.a_wlp2.PARENT_ITEM != None)).select(*fields, ...



On Tue, Oct 15, 2019 at 3:00 PM Massimiliano <mbelle...@gmail.com> wrote:

> fields = [db.s_disc_names.id.with_alias('id'),
>           db.s_disc_names.FULL_NAME-with_alias('full_name'),
>           db.a_wlp2.CHAIR.with_alias('chair')
>          ]
> subjects = db((db.a_groups.id == group) & (db.a_wlp2_distrib.MODULE ==
> module) & (db.a_wlp2.PARENT_ITEM != None)).select(*fields, ...
>
>
>
> On Tue, Oct 15, 2019 at 1:53 PM Константин Комков <fireandmi...@gmail.com>
> wrote:
>
>> I have that query:
>> sumAuditorHours = db.a_wlp2_distrib.LC_HOURS + db.a_wlp2_distrib.SM_HOURS
>> + db.a_wlp2_distrib.LB_HOURS
>> subjects = db((db.a_groups.id == group) & (db.a_wlp2_distrib.MODULE ==
>> module) & (db.a_wlp2.PARENT_ITEM != None)).select(db.s_disc_names.id
>> ,db.s_disc_names.FULL_NAME,db.a_wlp2.CHAIR,sumAuditorHours,orderby=db.s_disc_names.FULL_NAME,
>>     join=[db.a_wlp2.on(db.a_groups.WLP == db.a_wlp2.WLP),
>>     db.a_wlp2_distrib.on(db.a_wlp2.id == db.a_wlp2_distrib.WLP_ITEM),
>>     db.s_disc_names.on(db.a_wlp2.DISC_NAME == db.s_disc_names.id)]
>> )
>> db._lastsql looks like:
>> SELECT s_disc_names.id, s_disc_names.FULL_NAME, a_wlp2.CHAIR,
>> ((a_wlp2_distrib.LC_HOURS + a_wlp2_distrib.SM_HOURS) +
>> a_wlp2_distrib.LB_HOURS)
>> FROM a_groups
>> JOIN a_wlp2 ON (a_groups.WLP = a_wlp2.WLP)
>> JOIN a_wlp2_distrib ON (a_wlp2.id = a_wlp2_distrib.WLP_ITEM)
>> JOIN s_disc_names ON (a_wlp2.DISC_NAME = s_disc_names.id)
>> WHERE (((a_groups.id = 2277) AND (a_wlp2_distrib.MODULE = 3)) AND
>> (a_wlp2.PARENT_ITEM IS NOT NULL)) ORDER BY s_disc_names.FULL_NAME
>> How can I add *as my_column_name?*
>> Now rows looks like on picture.
>>
>> Thank you.
>>
>>
>>
>> --
>> 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/871e5991-8ddb-4c85-a1a9-72accc1c5aba%40googlegroups.com
>> <https://groups.google.com/d/msgid/web2py/871e5991-8ddb-4c85-a1a9-72accc1c5aba%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>
>
> --
> Massimiliano
>


-- 
Massimiliano

-- 
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/CANPTPxKc8HqS7JsU%2ByzB8FN4%2BDV7Oz8%3DR6DET98H-mD8xDojew%40mail.gmail.com.

Reply via email to