-- 2G
with master as (select m.datetime
                     , n.site_id
                     , n.cell_name
                     , n.cell
                     , n.band

                     , sum(tch_traffic_erlang)                                       as tch_traffic_erlang
                     , sum(sdcch_traffic_erlang)                                     as sdcch_traffic_erlang
                     , sum(edge_payload_dl_mbyte)                                    as edge_payload_dl_mbyte
                     , sum(edge_payload_ul_mbyte)                                    as edge_payload_ul_mbyte
                     , sum(gprs_payload_mbyte)                                       as gprs_payload_mbyte
                     , sum(num_tch_availability)                                     as num_tch_availability
                     , sum(denum_tch_availability)                                   as denum_tch_availability
                     , nds(sum(num_tch_availability), sum(denum_tch_availability))   as tch_availability
                     , sum(num_sdsr)                                                 as num_sdsr
                     , sum(denum_sdsr)                                               as denum_sdsr
                     , nds(sum(num_sdsr), sum(denum_sdsr))                           as sdsr
                     , sum(num_hosr)                                                 as num_hosr
                     , sum(denum_hosr)                                               as denum_hosr
                     , nds(sum(num_hosr), sum(denum_hosr))                           as hosr

                     , sum(num_tch_drop)                                             as num_tch_drop
                     , sum(denum_tch_drop)                                           as denum_tch_drop
                     , nds(sum(num_tch_drop), sum(denum_tch_drop))                   as tch_drop
                     , sum(num_tbf_dl_est_sr)                                        as num_tbf_dl_est_sr
                     , sum(denum_tbf_dl_est_sr)                                      as denum_tbf_dl_est_sr
                     , nds(sum(num_tbf_dl_est_sr), sum(denum_tbf_dl_est_sr))         as tbf_dl_est_sr
                     , sum(num_tbf_ul_est_sr)                                        as num_tbf_ul_est_sr
                     , sum(denum_tbf_ul_est_sr)                                      as denum_tbf_ul_est_sr

                     , nds(sum(num_tbf_ul_est_sr), sum(denum_tbf_ul_est_sr))         as tbf_ul_est_sr
                     , sum(num_tbf_comp_sr)                                          as num_tbf_comp_sr
                     , sum(denum_tbf_comp_sr)                                        as denum_tbf_comp_sr
                     , nds(sum(num_tbf_comp_sr), sum(denum_tbf_comp_sr))             as tbf_comp_sr
                     , sum(num_tch_block)                                            as num_tch_block
                     , sum(denum_tch_blok)                                           as denum_tch_blok
                     , nds(sum(num_tch_block), sum(denum_tch_blok))                  as tch_blok
                     , sum(num_sdcch_block)                                          as num_sdcch_block
                     , sum(denum_sdcch_block)                                        as denum_sdcch_block
                     , nds(sum(num_sdcch_block), sum(denum_sdcch_block))             as sdcch_block
                     , avg(edge_dl_throughput_kbps)                                  as edge_dl_throughput_kbps
                     , avg(gprs_dl_throughput_kbps)                                  as gprs_dl_throughput_kbps
                     , nds(sum(radio_utilization_num), sum(radio_utilization_denum)) as radio_utilization


                     , sum(number_of_trxs)                                           as number_of_trxs
                     , sum(num_dl_qual_0_5)                                          as num_dl_qual_0_5
                     , sum(denum_dl_qual_0_5)                                        as denum_dl_qual_0_5
                     , nds(sum(num_dl_qual_0_5), sum(denum_dl_qual_0_5))             as dl_qual_0_5

                     , sum(num_ul_qual_0_5)                                          as num_ul_qual_0_5
                     , sum(denum_ul_qual_0_5)                                        as denum_ul_qual_0_5
                     , nds(sum(num_ul_qual_0_5), sum(denum_ul_qual_0_5))             as ul_qual_0_5

                     , sum(num_icm_interference)                                     as num_icm_interference
                     , sum(denum_icm_interference)                                   as denum_icm_interference
                     , sum(number_of_abis_delete_ind_messages)                       as number_of_abis_delete_ind_messages
                     , sum(number_of_abis_ps_paging_messages)                        as number_of_abis_ps_paging_messages
                     , sum(number_of_abis_interface_paging_command_messages)         as number_of_abis_interface_paging_command_messages
                     , sum(tch_half_busy_time_s)                                     as tch_half_busy_time_s
                     , sum(tch_full_busy_time_s)                                     as tch_full_busy_time_s
                     , avg(data_integrity) / 100                                     as data_integrity

                from r11.meas_2g_hourly m
                         join network_cell n on m.network_cell_id = n.id

                where m.date between '2023-11-13' and date_int(0)
                  and n.site_id in ('TIM101', 'TIM142', 'TIM158', 'TIM161')

                group by m.datetime,
                         n.site_id,
                         n.cell_name,
                         n.cell,
                         n.band)
select *
from master
order by datetime
;

-- 4G
with master as (select m.datetime
                     , n.site_id
                     , n.cell_name
                     , n.cell
                     , n.band

                     , nds(sum(num_rrc_setup_sr), sum(denum_rrc_setup_sr))                                                                                                                                       as rrc_setup_sr
                     , sum(num_rrc_setup_sr)                                                                                                                                                                     as num_rrc_setup_sr
                     , sum(denum_rrc_setup_sr)                                                                                                                                                                   as denum_rrc_setup_sr

                     , nds(sum(num_rrc_setup_sr) * sum(num_e_rab_setup_sr) * sum(s1_signal_connection_est_sr_num), sum(denum_rrc_setup_sr) * sum(denum_e_rab_setup_sr) * sum(s1_signal_connection_est_sr_denum)) as cssr
                     , sum(num_rrc_setup_sr) * sum(num_e_rab_setup_sr) * sum(s1_signal_connection_est_sr_num)                                                                                                    as num_cssr
                     , sum(denum_rrc_setup_sr) * sum(denum_e_rab_setup_sr) * sum(s1_signal_connection_est_sr_denum)                                                                                              as denum_cssr

                     , nds(sum(num_e_rab_setup_sr), sum(denum_e_rab_setup_sr))                                                                                                                                   as e_rab_setup_sr
                     , sum(num_e_rab_setup_sr)                                                                                                                                                                   as num_e_rab_setup_sr
                     , sum(denum_e_rab_setup_sr)                                                                                                                                                                 as denum_e_rab_setup_sr

                     , nds(sum(num_e_rab_drop_rate_percent), sum(denum_e_rab_drop_rate_percent))                                                                                                                 as e_rab_drop_rate
                     , sum(num_e_rab_drop_rate_percent)                                                                                                                                                          as num_e_rab_drop_rate
                     , sum(denum_e_rab_drop_rate_percent)                                                                                                                                                        as denum_e_rab_drop_rate

                     , nds(sum(ratio_of_rrc_re_establishment_monitor_num), sum(ratio_of_rrc_re_establishment_monitor_denum))                                                                                     as ratio_of_rrc_re_establishment
                     , nds(sum(num_ifho_sr), sum(denum_ifho_sr))                                                                                                                                                 as ifho_sr
                     , sum(num_ifho_sr)                                                                                                                                                                          as num_ifho_sr
                     , sum(denum_ifho_sr)                                                                                                                                                                        as denum_ifho_sr

                     , nds(sum(num_csfb_sr), sum(denum_csfb_sr))                                                                                                                                                 as csfb_sr
                     , sum(num_csfb_sr)                                                                                                                                                                          as num_csfb_sr
                     , sum(denum_csfb_sr)                                                                                                                                                                        as denum_csfb_sr

                     , sum(number_of_rrc_connection_releases_triggered_by_csfb_times)                                                                                                                            as number_of_rrc_connection_releases_triggered_by_csfb_times
                     , sum(number_of_redirection_requests_from_lte_to_utran_csfb_times)                                                                                                                          as lte_number_of_redirection_requests_from_lte_to_utran_csfb_ranq
                     , sum(number_of_redirection_requests_from_lte_to_gsm_csfb_times)                                                                                                                            as lte_number_of_redirection_requests_from_lte_to_gsm_csfb_ranq

                     , nds(sum(s1_signal_connection_est_sr_num), sum(s1_signal_connection_est_sr_denum))                                                                                                         as s1_signaling_sr
                     , sum(dl_traffic_volume_mbyte)                                                                                                                                                              as dl_traffic_volume_mbyte
                     , sum(ul_traffic_volume_mbyte)                                                                                                                                                              as ul_traffic_volume_mbyte
                     , sum(payload_mbyte)                                                                                                                                                                        as payload_mbyte


                     , sum(maximum_number_of_rrc_connection_user_unit)                                                                                                                                           as maximum_number_of_rrc_connection_user
                     , sum(license_number_of_rrc_connection_user_cell_unit)                                                                                                                                      as license_number_of_rrc_connection_user

                     , nds(sum(num_dl_prb_utilization_percent), sum(denum_dl_prb_utilization_percent))                                                                                                           as dl_prb_utilization
                     , nds(sum(num_ul_prb_utilization_percent), sum(denum_ul_prb_utilization_percent))                                                                                                           as ul_prb_utilization
                     , nds(sum(cell_availability_num), sum(cell_availability_denum))                                                                                                                             as cell_availability

                     , avg(user_dl_throughput_kbps)                                                                                                                                                              as user_dl_throughput_kbps
                     , avg(user_ul_throughput_kbps)                                                                                                                                                              as user_ul_throughput_kbps
                     , avg(cell_dl_throughput_kbps)                                                                                                                                                              as cell_dl_throughput_kbps
                     , avg(cell_ul_throughput_kbps)                                                                                                                                                              as cell_ul_throughput_kbps

                     , nds(sum(dl_64qam_modulation_scheme_usage_num), sum(dl_64qam_modulation_scheme_usage_denum))                                                                                               as dl_64qam_modulation_scheme_usage
                     , nds(sum(ul_16qam_modulation_scheme_usage_num), sum(ul_16qam_modulation_scheme_usage_denum))                                                                                               as ul_16qam_modulation_scheme_usage

                     , nds(sum(the_ratio_of_cqi_ge_7_monitor_num), sum(the_ratio_of_cqi_ge_7_monitor_denum))                                                                                                     as the_ratio_of_cqi_ge_7_monitor

                     , nds(sum(prb_number_used_on_downlink_channel_unit), sum(prb_number_available_on_downlink_channel_unit))                                                                                    as dl_resource_block_utilizing_rate
                     , nds(sum(prb_number_used_on_uplink_channel_unit), sum(prb_number_available_on_uplink_channel_unit))                                                                                        as ul_resource_block_utilizing_rate

                     , nds(sum(cce_number_used_on_pdcch_channel_unit), sum(cce_number_available_on_pdcch_channel_unit))                                                                                          as pdcch_cce_utilization_rate
                     , nds(sum(prb_number_used_on_pusch_channel_unit), sum(prb_number_available_on_pusch_channel_unit))                                                                                          as pusch_prb_utilization_rate
                     , nds((sum(number_of_successful_access_using_group_a_preamble_unit) + sum(number_of_successful_access_using_group_b_preamble_unit) + sum(number_of_successful_access_using_dedicated_preamble_unit))
        , sum(number_of_available_preamble_unit))                                                                                                                                                                as prach_usage

                     , nds(sum(dl_qpsk_modulation_scheme_usage_num), sum(dl_qpsk_modulation_scheme_usage_denum))                                                                                                 as dl_qpsk_modulation_scheme_usage
                     , nds(sum(dl_16qam_modulation_scheme_usage_num), sum(dl_16qam_modulation_scheme_usage_denum))                                                                                               as dl_16qam_modulation_scheme_usage
                     , nds(sum(dl_qpsk_modulation_scheme_usage_num), sum(ul_qpsk_modulation_scheme_usage_denum))                                                                                                 as ul_qpsk_modulation_scheme_usage
                     , nds(sum(ul_64qam_modulation_scheme_usage_num), sum(ul_64qam_modulation_scheme_usage_denum))                                                                                               as ul_64qam_modulation_scheme_usage

                     , sum(number_of_paging_records_received_by_the_enodeb_unit)                                                                                                                                 as paging_number_from_s1

                     , nds(sum(number_of_paging_records_congested_at_the_enodeb_unit), sum(number_of_paging_records_received_by_the_enodeb_unit) + sum(number_of_paging_records_congested_at_the_enodeb_unit))   as paging_congestion_rate
                     , nds(sum(number_of_paging_records_received_by_the_enodeb_unit), sum(number_of_paging_records_send_from_enodeb_unit))                                                                       as paging_success_rate
                     , avg(active_users_rnp)                                                                                                                                                                     as active_users_rnp
                     , nds(sum(dl_256qam_modulation_scheme_usage_num), sum(dl_256qam_modulation_scheme_usage_denum))                                                                                             as dl_256qam_modulation_scheme_usage


                     , avg(average_cqi)                                                                                                                                                                          as average_cqi
                     , avg(cqi_ge_10)                                                                                                                                                                            as cqi_ge_10
                     , avg(spectral_efficiency)                                                                                                                                                                  as spectral_efficiency

                     , nds(sum(inter_freq_lte_ho_num), sum(inter_freq_lte_ho_denum))                                                                                                                             as inter_freq_lte_ho
                     , sum(inter_freq_lte_ho_denum)                                                                                                                                                              as inter_freq_lte_ho_denum
                     , sum(inter_freq_lte_ho_num)                                                                                                                                                                as inter_freq_lte_ho_num

                     , sum(num_ifho_sr)                                                                                                                                                                          as num_ifho_sr_
                     , sum(denum_ifho_sr)                                                                                                                                                                        as denum_ifho_sr_
                     , avg(cell_dl_tcp_packets_average_rtt_ms)                                                                                                                                                   as cell_dl_tcp_packets_average_rtt
                     , avg(kpi_average_dl_pdcp_sdu_delay_ms)                                                                                                                                                     as average_dl_pdcp_sdu_delay
                     , avg(kpi_average_dl_ip_packet_delay_ms)                                                                                                                                                    as average_dl_ip_packet_delay
                     , avg(avgerage_delay_of_tcp_three_way_handshake_syn_to_synack_ms)                                                                                                                           as average_delay_of_tcp_three_way_handshake_syn_to_synack
                     , avg(avgerage_delay_of_tcp_three_way_handshake_synack_to_ack_ms)                                                                                                                           as average_delay_of_tcp_three_way_handshake_synack_to_ack
                     , avg(avgerage_delay_of_tcp_three_way_handshake_ack_to_firstdata_ms)                                                                                                                        as average_delay_of_tcp_three_way_handshake_ack_to_firstdata

                     , avg(average_ni_of_carrier_dbm)                                                                                                                                                            as average_ni_of_carrier_dbm


                     , nds(sum(rrc_establishment_volte_num) * sum(e_rab_setup_volte_qci5_num),
                           sum(rrc_establishment_volte_denum) * sum(e_rab_setup_volte_qci5_denum))                                                                                                               as call_setup_sr_qci_1_qci_5
                     , sum(rrc_establishment_volte_num) * sum(e_rab_setup_volte_qci5_num)                                                                                                                        as call_setup_sr_qci_1_qci_5_num
                     , sum(rrc_establishment_volte_denum) * sum(e_rab_setup_volte_qci5_denum)                                                                                                                    as call_setup_sr_qci_1_qci_5_denum

                     , nds(sum(e_rab_setup_volte_qci1_num) + sum(e_rab_setup_volte_qci5_num),
                           sum(e_rab_setup_volte_qci1_denum) + sum(e_rab_setup_volte_qci5_denum))                                                                                                                as e_rab_setup_sr_qci_1_qci_5
                     , sum(e_rab_setup_volte_qci1_num) + sum(e_rab_setup_volte_qci5_num)                                                                                                                         as e_rab_setup_sr_qci_1_qci_5_num
                     , sum(e_rab_setup_volte_qci1_denum) + sum(e_rab_setup_volte_qci5_denum)                                                                                                                     as e_rab_setup_sr_qci_1_qci_5_denum

                     , nds(sum(volte_call_drop_rate_mme_num), sum(volte_call_drop_rate_mme_denum))                                                                                                               as call_drop_rate_mme
                     , sum(volte_call_drop_rate_mme_num)                                                                                                                                                         as call_drop_rate_mme_num
                     , sum(volte_call_drop_rate_mme_denum)                                                                                                                                                       as call_drop_rate_mme_denum

                     , nds(sum(volte_call_drop_rate_num), sum(volte_call_drop_rate_denum))                                                                                                                       as call_drop_rate
                     , sum(volte_call_drop_rate_num)                                                                                                                                                             as call_drop_rate_num
                     , sum(volte_call_drop_rate_denum)                                                                                                                                                           as call_drop_rate_denum

                     , sum(volte_traffic_erl)                                                                                                                                                                    as traffic_erl
                     , sum(maximum_dl_active_user_number_qci_1_unit)                                                                                                                                             as maximum_dl_active_user_number_qci_1

                     , nds(sum(volte_user_outgoing_inter_freq_hosr_num), sum(volte_user_outgoing_inter_freq_hosr_denum))                                                                                         as user_outgoing_inter_freq_hosr
                     , sum(volte_user_outgoing_inter_freq_hosr_num)                                                                                                                                              as user_outgoing_inter_freq_hosr_num
                     , sum(volte_user_outgoing_inter_freq_hosr_denum)                                                                                                                                            as user_outgoing_inter_freq_hosr_denum

                     , nds(sum(volte_user_outgoing_intra_freq_hosr_num), sum(volte_user_outgoing_intra_freq_hosr_denum))                                                                                         as user_outgoing_intra_freq_hosr
                     , sum(volte_user_outgoing_intra_freq_hosr_num)                                                                                                                                              as user_outgoing_intra_freq_hosr_num
                     , sum(volte_user_outgoing_intra_freq_hosr_denum)                                                                                                                                            as user_outgoing_intra_freq_hosr_denum

                     , nds(sum(volte_srvcc_ho_sr_lte_to_umts_success_div_success_failure_num), sum(volte_srvcc_ho_sr_lte_to_umts_success_div_success_failure_denum))                                             as srvcc_hosr_lte_umts_succ_div_succ_plus_fail
                     , sum(volte_srvcc_ho_sr_lte_to_umts_success_div_success_failure_num)                                                                                                                        as srvcc_hosr_lte_umts_succ_div_succ_plus_fail_num
                     , sum(volte_srvcc_ho_sr_lte_to_umts_success_div_success_failure_denum)                                                                                                                      as srvcc_hosr_lte_umts_succ_div_succ_plus_fail_denum

                     , nds(sum(volte_srvcc_ho_sr_lte_to_gsm_success_div_success_failure_num), sum(volte_srvcc_ho_sr_lte_to_gsm_success_div_success_failure_denum))                                               as srvcc_hosr_lte_gsm_succ_div_succ_plus_fail
                     , sum(volte_srvcc_ho_sr_lte_to_gsm_success_div_success_failure_num)                                                                                                                         as srvcc_hosr_lte_gsm_succ_div_succ_plus_fail_num
                     , sum(volte_srvcc_ho_sr_lte_to_gsm_success_div_success_failure_denum)                                                                                                                       as srvcc_hosr_lte_gsm_succ_div_succ_plus_fail_denum

                     , nds(sum(num_erab_setup_success_rate_xhj), sum(denum_erab_setup_success_rate_xhj))                                                                                                         as erab_setup_success_rate
                     , sum(num_erab_setup_success_rate_xhj)                                                                                                                                                      as num_erab_setup_success_rate
                     , sum(denum_erab_setup_success_rate_xhj)                                                                                                                                                    as denum_erab_setup_success_rate

                     , avg(data_integrity)

                from r11.meas_4g_hourly m
                         join network_cell n on m.network_cell_id = n.id

                where m.date between '2023-11-13' and date_int(0)
                  and n.site_id in ('TIM101', 'TIM142', 'TIM158', 'TIM161')

                group by m.datetime,
                         n.site_id,
                         n.cell_name,
                         n.cell,
                         n.band)
select *
from master
order by datetime
;


------ 55G 


with master as (select m.datetime
                     , n.site_id
                     , n.cell_name
                     , n.cell
                     , n.band

                     , sum(num_availability)                                                                      as num_availability
                     , 0                                                                                          as denum_availability
                     , AVG(availability)                                                                          as availability
                     , sum(number_of_times_that_an_sn_is_added_successfully)                                      as num_setup_success_rate
                     , sum(number_of_sn_add_requests)                                                             as denum_setup_success_rate
                     , nds(sum(number_of_times_that_an_sn_is_added_successfully), sum(number_of_sn_add_requests)) as setup_success_rate

                     , sum(nr_retainability_num)                                                                  as num_retainability
                     , sum(nr_retainability_denum)                                                                as denum_retainability
                     , nds(sum(nr_retainability_num), sum(nr_retainability_denum)) / 100                          as retainability
                     , sum(num_prb_utilization_ul)                                                                as num_prb_utilization_ul
                     , sum(denum_prb_utilization_ul)                                                              as denum_prb_utilization_ul
                     , nds(sum(num_prb_utilization_ul), sum(denum_prb_utilization_ul)) / 100                      as prb_utilization_ul
                     , sum(num_prb_utilization_dl)                                                                as num_prb_utilization_dl
                     , sum(denum_prb_utilization_dl)                                                              as denum_prb_utilization_dl
                     , nds(sum(num_prb_utilization_dl), sum(denum_prb_utilization_dl)) / 100                      as prb_utilization_dl
                     , sum(num_inter_handover_success_rate)                                                       as num_inter_handover_success_rate
                     , sum(denum_inter_handover_success_rate)                                                     as denum_inter_handover_success_rate
                     , nds(sum(num_inter_handover_success_rate), sum(denum_inter_handover_success_rate))          as inter_handover_success_rate
                     , sum(num_intra_handover_success_rate)                                                       as num_intra_handover_success_rate
                     , sum(denum_intra_handover_success_rate)                                                     as denum_intra_handover_success_rate
                     , nds(sum(num_intra_handover_success_rate), sum(denum_intra_handover_success_rate))          as intra_handover_success_rate

                     , avg(prb_ussage_ul)                                                                         as prb_ussage_ul
                     , avg(prb_ussage_dl)                                                                         as prb_ussage_dl
                     , avg(user_throughput_ul)                                                                    as user_throughput_ul
                     , avg(user_throughput_dl)                                                                    as user_throughput_dl
                     , avg(cell_throughput_ul)                                                                    as cell_throughput_ul
                     , avg(cell_throughput_dl)                                                                    as cell_throughput_dl
                     , sum(payload_dl)                                                                            as payload_dl_mbyte
                     , sum(payload_ul)                                                                            as payload_ul_mbyte
                     , sum(payload)                                                                               as payload_mbyte
                     , avg(avg_active_user_number)                                                                as avg_active_user
                     , max(max_active_user_number)                                                                as max_active_user
                     , avg(avg_rrc_user_number)                                                                   as avg_rrc_user
                     , max(max_rrc_user_number)                                                                   as max_rrc_user
                     , avg(average_cqi)                                                                           as average_cqi
                     , avg(average_cqi_64_qam)                                                                    as average_cqi_64_qam
                     , avg(average_cqi_256_qam)                                                                   as average_cqi_256_qam
                     , avg(avg_uplink_interference)                                                               as avg_uplink_interference
                     , max(max_uplink_interference)                                                               as max_uplink_interference
                     , avg(spectrum_eff)                                                                          as spectrum_eff
                     , avg(latency_ul)                                                                            as latency_ul
                     , avg(latency_dl)                                                                            as latency_dl
                     , avg(packet_loss)                                                                           as packet_loss
                     , avg(avr_ta)                                                                                as avr_ta

                     , sum(number_of_bytes_of_ul_pdcp_services_mbyte)                                             as number_of_bytes_of_ul_pdcp_services_mbyte
                     , sum(number_of_bytes_of_dl_pdcp_services_mbyte)                                             as number_of_bytes_of_dl_pdcp_services_mbyte
                     , sum(number_of_sn_change_confirmations)                                                     as number_of_sn_change_confirmations
                     , sum(number_of_sn_change_requests)                                                          as number_of_sn_change_requests
                     , nds(sum(nr_retainability_num), sum(nr_retainability_denum)) / 100                          as nr_retainability
                     , nds(sum(nr_mobility_num), sum(nr_mobility_denum)) / 100                                    as nr_mobility

                     , sum(num_latency_dl)                                                                        as num_latency_dl_xhj
                     , sum(denum_latency_dl)                                                                      as denum_latency_dl_xhj
                     , sum(num_packet_loss)                                                                       as num_packet_loss_xhj
                     , sum(denum_packet_loss)                                                                     as denum_packet_loss_xhj

                     , sum(num_cell_throughput_dl)                                                                as num_cell_throughput_dl
                     , sum(num_cell_throughput_ul)                                                                as num_cell_throughput_ul
                     , sum(num_user_throughput_dl)                                                                as num_user_throughput_dl
                     , sum(denum_user_throughput_dl)                                                              as denum_user_throughput_dl
                     , sum(num_user_throughput_ul)                                                                as num_user_throughput_ul
                     , sum(denum_user_throughput_ul)                                                              as denum_user_throughput_ul
                     , sum(num_latency_ul)                                                                        as num_latency_ul
                     , sum(denum_latency_ul)                                                                      as denum_latency_ul


                     , sum(num_average_cqi)                                                                       as num_average_cqi
                     , sum(denum_average_cqi)                                                                     as denum_average_cqi
                     , sum(num_average_cqi_64_qam)                                                                as num_average_cqi_64_qam
                     , sum(denum_average_cqi_64_qam)                                                              as denum_average_cqi_64_qam
                     , sum(num_average_cqi_256_qam)                                                               as num_average_cqi_256_qam
                     , sum(denum_verage_cqi_256_qam)                                                              as denum_verage_cqi_256_qam
                     , sum(num_spectrum_eff)                                                                      as num_spectrum_eff
                     , sum(denum_spectrum_eff)                                                                    as denum_spectrum_eff

                from r11.meas_5g_hourly m
                         join network_cell n on m.network_cell_id = n.id

                where m.date between '2023-11-13' and date_int(0)
                  and n.site_id in ('TIM101', 'TIM142', 'TIM158', 'TIM161')

                group by m.datetime,
                         n.site_id,
                         n.cell_name,
                         n.cell,
                         n.band)
select *
from master
order by datetime
;