|
|
|
LEFT JOIN/UNION
|
|||
|---|---|---|---|
|
#18+
Добрый день! У меня проблема с объединением двух запросов. Первый запрос считает открытые/закрытые установки по услугам связи А, второй запрос считает открытые/закрытые установки по услугам связи Б. Мне необходимо вывести результат одним запросом. В Результате должно быть 5 столбцов. Регион Открытые СТС, Закрытые СТС, Открытые ГТС, Закрытые ГТС пример. --Атырау СТС select trim(r.name) "РЕГИОН", sum(case when od.end_sysdate is not null then 1 end)"Закрытые СТС" , --ЭТО УСЛУГА А sum(case when od.end_sysdate is null then 1 end) "Открытые СТС" from db.order_device od, db.report_date rd, db.device_group dg, db.connect_type ct, db.town t, db.region r, db.crm_server cs, (select 383074 id from dual union select 144786 from dual) tab where tab.id=od.abonent_id and od.new_connect_type_id=ct.id and od.begin_sysdate between rd.from_date and rd.to_date and rd.id=11 and dg.id=od.device_group_id and dg.id= decode(cs.id, 3, 24, 13, 33, 4, 37, 11, 24, -1) and od.town_id=t.id and t.region_id=r.id and od.action_id in (9) group by r.name ------------------------ --Атырау ГТС union all select trim(r.name) "РЕГИОН", sum(case when od.end_sysdate is not null then 1 end)Закрытые ГТС, --ЭТО Услуга Б sum(case when od.end_sysdate is null then 1 end) "Открытые ГТС" from db.order_device od, db.report_date rd, db.device_group dg, db.connect_type ct, db.town t, db.region r, db.crm_server cs, (select 131690 id from dual union select 343792 from dual) tab where tab.id=od.abonent_id and od.new_connect_type_id=ct.id and od.begin_sysdate between rd.from_date and rd.to_date and rd.id=11 and dg.id=od.device_group_id and dg.id= decode(cs.id, 3, 24, 13, 33, 4, 37, 11, 24, -1) and od.town_id=t.id and t.region_id=r.id and od.action_id in (9) group by r.name order by 1 ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 10.12.2018, 10:07 |
|
||
|
LEFT JOIN/UNION
|
|||
|---|---|---|---|
|
#18+
Код: plsql 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 10.12.2018, 10:22 |
|
||
|
|

start [/forum/topic.php?fid=52&tid=1883064]: |
0ms |
get settings: |
6ms |
get forum list: |
13ms |
check forum access: |
2ms |
check topic access: |
2ms |
track hit: |
154ms |
get topic data: |
7ms |
get forum data: |
2ms |
get page messages: |
30ms |
get tp. blocked users: |
1ms |
| others: | 207ms |
| total: | 424ms |

| 0 / 0 |
