zquery/V2/QueryTemplate/region_weekly_productivity.sql

102 lines
3.5 KiB
SQL

-- V1
with master as (select n.region
, n.tech
, m.yearweek
, sum(tch_traffic_erlang) as traffic_erl
, sum(payload_mbyte) as payload_mbyte
from meas_2g_daily m
join network_cell n on m.network_cell_id = n.id
join ref_site r on n.site_id = r.site_id
where m.date between date_from('202401') and date_to('202402')
group by n.region
, n.tech
, m.yearweek
union all
select n.region
, n.tech
, m.yearweek
, sum(volte_traffic_erl) as traffic
, sum(payload_mbyte) as payload_mbyte
from meas_4g_daily m
join network_cell n on m.network_cell_id = n.id
join ref_site r on n.site_id = r.site_id
where m.date between date_from('202401') and date_to('202402')
group by n.region
, n.tech
, m.yearweek
union all
select n.region
, n.tech
, m.yearweek
, 0 as traffic
, sum(payload) as payload_mbyte
from meas_5g_daily m
join network_cell n on m.network_cell_id = n.id
join ref_site r on n.site_id = r.site_id
where m.date between date_from('202401') and date_to('202402')
group by n.region
, n.tech
, m.yearweek)
select region
, tech
, yearweek
, traffic_erl::numeric(100, 2) as traffic_erl
, payload_mbyte::numeric(100, 2) as payload_mbyte
from master
order by region, tech, yearweek
;
-- V2 lebih cepat
with master as (select region
, tech
, yearweek
, sum(tch_traffic_erlang) as traffic_erl
, sum(payload_mbyte) as payload_mbyte
from app.fact_category_kpi_2g_daily
where level_type = 'REGION'
and all_band = true
and date between date_from('202401') and date_to('202402')
group by region, tech, yearweek
union all
select region
, tech
, yearweek
, sum(volte_traffic_erl) as traffic
, sum(payload_mbyte) as payload_mbyte
from app.fact_category_kpi_4g_daily
where level_type = 'REGION'
and all_band = true
and date between date_from('202401') and date_to('202402')
group by region, tech, yearweek
union all
select region
, tech
, yearweek
, 0 as traffic
, sum(payload) as payload_mbyte
from app.fact_category_kpi_5g_daily
where level_type = 'REGION'
and all_band = true
and date between date_from('202401') and date_to('202402')
group by region, tech, yearweek)
select region
, tech
, yearweek
, traffic_erl::numeric(100, 2) as traffic_erl
, payload_mbyte::numeric(100, 2) as payload_mbyte
from master
order by region, tech, yearweek
;