Проект

Общее

Профиль

Для ПЭУ: Собрать информацию по районам, организациям, объектам с указанием объемов и сумм по услуге "отопление" с разбиением на полугодиям по плану 2021

Техническая документация
24.12.2021

select offi.name,org.name,obj.name,sum(pa.volume) as volum,sum(pa.summa) as summa,sum(pa.nds) as nds, '1 полугодие' as periud from com_jur2021..planned_accrual pa
left join com_jur_spr..offices offi on pa.id_office = offi.id
left join com_jur_spr..organizations org on pa.id_organization = org.id
left join com_jur_spr..objects obj on pa.id_object = obj.id
where pa.id_service = 1 and pa.id_organization not in (select id from com_jur_spr..organizations where central = 1 and id_office <> 37) and pa.tariff_to_htw is not null
and pa.month < 7
group by offi.name,org.name,obj.name
union
select offi.name,org.name,obj.name,sum(pa.volume) as volum,sum(pa.summa) as summa,sum(pa.nds) as nds, '2 полугодие' as periud from com_jur2021..planned_accrual pa
left join com_jur_spr..offices offi on pa.id_office = offi.id
left join com_jur_spr..organizations org on pa.id_organization = org.id
left join com_jur_spr..objects obj on pa.id_object = obj.id
where pa.id_service = 1 and pa.id_organization not in (select id from com_jur_spr..organizations where central = 1 and id_office <> 37) and pa.tariff_to_htw is not null
and pa.month > 6
group by offi.name,org.name,obj.name

Файлы