INSERT INTO ON_DEMAND_WEBSERVICESEXECUTION_RABI_SUMMARIZED_TB (STYPE, UNIQUE_COUNT_SCOMPID, REQUESTS, PERIOD)
SELECT
    stype,
    count(distinct scompid) AS unique_count_scompid,
    sum(doc_count) AS requests,
    trunc(metadata_downloaded_timestamp_utc, 'MM') AS period
FROM
    src_osearch_webservicesexecution_rabi_tb
WHERE
    metadata_downloaded_timestamp_utc < trunc(sysdate, 'MM')
GROUP BY
    STYPE,
    trunc(metadata_downloaded_timestamp_utc, 'MM');
    
    select * from ON_DEMAND_WEBSERVICESEXECUTION_RABI_SUMMARIZED_TB;