From d40c0b401aef1560bf99132461d2ba2b814fcb37 Mon Sep 17 00:00:00 2001 From: adekurniawan Date: Thu, 14 Dec 2023 17:30:26 +0700 Subject: [PATCH] update productivity sql --- QueryTemplate/site_daily_productivity.sql | 161 ++++++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100644 QueryTemplate/site_daily_productivity.sql diff --git a/QueryTemplate/site_daily_productivity.sql b/QueryTemplate/site_daily_productivity.sql new file mode 100644 index 0000000..e84f6bb --- /dev/null +++ b/QueryTemplate/site_daily_productivity.sql @@ -0,0 +1,161 @@ +with master_r08 as (select n.region + , n.tech + , m.date + , site_id + , 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 + where m.date between '2023-12-01' and '2023-12-07' +-- and n.site_id in ('AMB002') + group by n.region + , n.tech + , m.date + , site_id + + union all + + select n.region + , n.tech + , m.date + , site_id + , 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 + where m.date between '2023-12-01' and '2023-12-07' +-- and n.site_id in ('AMB002') + group by n.region + , n.tech + , m.date + , site_id + + union all + + select n.region + , n.tech + , m.date + , site_id + , 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 + where m.date between '2023-12-01' and '2023-12-07' +-- and n.site_id in ('AMB002') + group by n.region + , n.tech + , m.date + , site_id), + master_r09 as (select n.region + , n.tech + , m.date + , site_id + , 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 + where m.date between '2023-12-01' and '2023-12-07' +-- and n.site_id in ('AMB002') + group by n.region + , n.tech + , m.date + , site_id + + union all + + select n.region + , n.tech + , m.date + , site_id + , 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 + where m.date between '2023-12-01' and '2023-12-07' +-- and n.site_id in ('AMB002') + group by n.region + , n.tech + , m.date + , site_id + + union all + + select n.region + , n.tech + , m.date + , site_id + , 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 + where m.date between '2023-12-01' and '2023-12-07' +-- and n.site_id in ('AMB002') + group by n.region + , n.tech + , m.date + , site_id), + master_r11 as (select n.region + , n.tech + , m.date + , site_id + , 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 + where m.date between '2023-12-01' and '2023-12-07' +-- and n.site_id in ('AMB002') + group by n.region + , n.tech + , m.date + , site_id + + union all + + select n.region + , n.tech + , m.date + , site_id + , 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 + where m.date between '2023-12-01' and '2023-12-07' +-- and n.site_id in ('AMB002') + group by n.region + , n.tech + , m.date + , site_id + + union all + + select n.region + , n.tech + , m.date + , site_id + , 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 + where m.date between '2023-12-01' and '2023-12-07' +-- and n.site_id in ('AMB002') + group by n.region + , n.tech + , m.date + , site_id), + combined as (select * + from master_r08 + union all + select * + from master_r09 + union all + select * + from master_r11) +select region + , tech + , date + , site_id + , traffic_erl::numeric(100, 2) as traffic_erl + , payload_mbyte::numeric(100, 2) as payload_mbyte +from combined +order by region, tech, site_id, date +; \ No newline at end of file