SELECT yearweek                                                                                                                AS week
     , 'PUMA'                                                                                                                  as regional
     , SUM(num_hosr)                                                                                                           AS z_hosr_num
     , SUM(denum_hosr)                                                                                                         AS z_hosr_denum
     , case when SUM(denum_hosr) = 0 then 0 else SUM(num_hosr) / SUM(denum_hosr) * 100 end                                     as hosr
     , SUM(num_sdsr)                                                                                                           AS z_sdsr_num
     , SUM(denum_sdsr)                                                                                                         AS z_sdsr_denum
     , case when SUM(denum_sdsr) = 0 then 0 else SUM(num_sdsr) / SUM(denum_sdsr) * 100 end                                     as sdsr
     , SUM(num_tch_drop)                                                                                                       AS z_tchdrop_num
     , SUM(denum_tch_drop)                                                                                                     AS z_tchdrop_denum
     , case when SUM(denum_tch_drop) = 0 then 0 else SUM(num_tch_drop) / SUM(denum_tch_drop) * 100 end                         as tchdrop
     , SUM(num_tbf_ul_est_sr)                                                                                                  AS z_tbful_est_sr_num
     , SUM(denum_tbf_ul_est_sr)                                                                                                AS z_tbful_est_sr_denum
     , case when SUM(denum_tbf_ul_est_sr) = 0 then 0 else SUM(num_tbf_ul_est_sr) / SUM(denum_tbf_ul_est_sr) * 100 end          as tbful_est_sr
     , SUM(num_tbf_comp_sr)                                                                                                    AS z_tbfcomp_sr_num
     , SUM(denum_tbf_comp_sr)                                                                                                  AS z_tbfcomp_sr_denum
     , case when SUM(denum_tbf_comp_sr) = 0 then 0 else SUM(num_tbf_comp_sr) / SUM(denum_tbf_comp_sr) * 100 end                as tbfcomp_sr
     , SUM(num_tch_block)                                                                                                      AS z_tch_block_num
     , SUM(denum_tch_blok)                                                                                                     AS z_tch_block_denum
     , case when SUM(denum_tch_blok) = 0 then 0 else SUM(num_tch_block) / SUM(denum_tch_blok) * 100 end                        as tch_block
     , SUM(num_sdcch_block)                                                                                                    AS z_sdblock_num
     , SUM(denum_sdcch_block)                                                                                                  AS z_sdblock_denum
     , case when SUM(denum_sdcch_block) = 0 then 0 else SUM(num_sdcch_block) / SUM(denum_sdcch_block) * 100 end                as sdblock
     , AVG(edge_dl_throughput_kbps)                                                                                            AS EDGE_Throughput
     , AVG(gprs_dl_throughput_kbps)                                                                                            AS GPRS_Throughput
     , SUM(gprs_payload_mbyte)                                                                                                 AS GPRS_Payload_mbyte
     , SUM(edge_payload_ul_mbyte) + SUM(edge_payload_dl_mbyte)                                                                 AS EDGE_Payload_mbyte
     , SUM(tch_traffic_erlang)                                                                                                 AS z_tch_traffic
     , SUM(sdcch_traffic_erlang)                                                                                               AS z_sdcch_traffic
     , sum(num_tch_availability)                                                                                               AS Availability_2G_NUM
     , sum(denum_tch_availability)                                                                                             AS Availability_2G_DENUM
     , coalesce(sum(num_tch_availability) / nullif(sum(denum_tch_availability), 0) * 100, 0)                                   AS Availability_2G
     , SUM(num_tbf_dl_est_sr)                                                                                                  AS z_tbfdl_est_sr_num
     , SUM(denum_tbf_dl_est_sr)                                                                                                AS z_tbfdl_est_sr_denum
     , case when SUM(denum_tbf_dl_est_sr) = 0 then 0 else SUM(num_tbf_dl_est_sr) / SUM(denum_tbf_dl_est_sr) * 100 end          as tbfdl_est_sr
     , SUM(num_icm_interference)                                                                                               AS z_inter_vrnc_num
     , SUM(denum_icm_interference)                                                                                             AS z_inter_vrnc_denum
     , case when SUM(denum_icm_interference) = 0 then 0 else SUM(num_icm_interference) / SUM(denum_icm_interference) * 100 end as interference
     , SUM(num_dl_qual_0_5)                                                                                                    AS z_dlqual5_num
     , SUM(denum_dl_qual_0_5)                                                                                                  AS z_dlqual5_denum
     , case when SUM(denum_dl_qual_0_5) = 0 then 0 else SUM(num_dl_qual_0_5) / SUM(denum_dl_qual_0_5) * 100 end                as z_dlqual5
     , SUM(num_ul_qual_0_5)                                                                                                    AS z_ulqual5_num
     , SUM(denum_ul_qual_0_5)                                                                                                  AS z_ulqual5_denum
     , case when SUM(denum_ul_qual_0_5) = 0 then 0 else SUM(num_ul_qual_0_5) / SUM(denum_ul_qual_0_5) * 100 end                as z_ulqual5
     , SUM(payload_mbyte)                                                                                                      AS Total_Payload
FROM r11.meas_2g_daily m
where date between date_from('202332') and date_to('202349')
group by yearweek
order by yearweek
;

