select nper, witel, sto, alpro, odc, plblcl, count() lis from
(select b.
from mart_nonatero.nnt_lis_line_odc_2021 b
left join mart_nonatero.proman_p_sektor_sto_map d on b.sto=d.csto and d.map_type in (0,1)
left join mart_nonatero.proman_p_sektor_odc_map e on b.odc='ODP-'||e.odc and b.sto=e.csto
where 1=1
and nper='202106'
and is_billed='1'
and d.csto is null and e.csto is null)
group by nper, witel, sto, alpro, odc, plblcl
order by nper, witel, sto, alpro, odc, plblcl;
Divisor
Select reg, witel, sektor, sum(lis) from lis_sektor
Where plblcl=PL
-