h4wkcomparison monthly
    Updated 2023-04-16
    -- -- forked from comparison @ https://flipsidecrypto.xyz/edit/queries/d1ea3797-381c-4090-bf70-106347884fa3

    -- -- FLOW
    with flow_total_avg_for_minute as (
    select
    date_trunc('month', block_timestamp) as date,
    count(*)/count(distinct block_timestamp::date)/1440 as tx_per_min
    from flow.core.fact_transactions
    where block_timestamp::date < CURRENT_DATE and block_timestamp::date >= '2022-01-01'
    group by 1
    )

    , flow_success_per_min as (select
    date_trunc('month', block_timestamp) as date,
    count(*)/count(distinct block_timestamp::date)/1440 as tx_per_min
    from flow.core.fact_transactions
    where block_timestamp::date < CURRENT_DATE and block_timestamp::date >= '2022-01-01'
    and tx_succeeded = True group by 1
    )
    , base_flow as (
    select * from (
    select date, tx_per_min, 'Total' as type from (select * from flow_total_avg_for_minute)
    UNION
    select date, tx_per_min, 'Success' as type from (select * from flow_success_per_min)
    ) order by type
    )
    , final_flow as (
    select date,
    'Flow' as chain,
    sum(case when type = 'Total' then tx_per_min end) as tpm,
    sum(case when type = 'Success' then tx_per_min end) as stpm,
    stpm/tpm*100 as percentage
    from base_flow group by 1,2
    )


    Run a query to Download Data