From fdf88dc6fdba1592280388317405cc49e8a163f3 Mon Sep 17 00:00:00 2001 From: adekurniawan Date: Tue, 2 Jan 2024 18:04:09 +0700 Subject: [PATCH] update query --- QueryTemplate/region_weekly_productivity.sql | 192 +++++++++++++++++++ 1 file changed, 192 insertions(+) create mode 100644 QueryTemplate/region_weekly_productivity.sql diff --git a/QueryTemplate/region_weekly_productivity.sql b/QueryTemplate/region_weekly_productivity.sql new file mode 100644 index 0000000..bd121b9 --- /dev/null +++ b/QueryTemplate/region_weekly_productivity.sql @@ -0,0 +1,192 @@ +-- V1 +with master_r08 as (select n.region + , n.tech + , m.yearweek + , sum(tch_traffic_erlang) as traffic_erl + , sum(payload_mbyte) as payload_mbyte + from r08.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('202346') and date_to('202352') + 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 r08.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('202346') and date_to('202352') + 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 r08.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('202346') and date_to('202352') + group by n.region + , n.tech + , m.yearweek), + master_r09 as (select n.region + , n.tech + , m.yearweek + , sum(tch_traffic_erlang) as traffic_erl + , sum(payload_mbyte) as payload_mbyte + from r09.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('202346') and date_to('202352') + 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 r09.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('202346') and date_to('202352') + 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 r09.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('202346') and date_to('202352') + group by n.region + , n.tech + , m.yearweek), + master_r11 as (select n.region + , n.tech + , m.yearweek + , sum(tch_traffic_erlang) as traffic_erl + , sum(payload_mbyte) as payload_mbyte + from r11.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('202346') and date_to('202352') + 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 r11.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('202346') and date_to('202352') + 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 r11.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('202346') and date_to('202352') + group by n.region + , n.tech + , m.yearweek), + combined as (select * + from master_r08 + union all + select * + from master_r09 + union all + select * + from master_r11) +select region + , tech + , yearweek + , traffic_erl::numeric(100, 2) as traffic_erl + , payload_mbyte::numeric(100, 2) as payload_mbyte +from combined +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('202346') and date_to('202352') + 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('202346') and date_to('202352') + 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('202346') and date_to('202352') + 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 +; + +