thea[Near] Network Mega
    Updated 2023-01-06
    with time_frame as (
    select case
    when '{{quarter}}' = '2022 Q4' then '2022-10-01'
    when '{{quarter}}' = '2022 Q3' then '2022-07-01'
    when '{{quarter}}' = '2022 Q2' then '2022-04-01'
    when '{{quarter}}' = '2022 Q1' then '2022-01-01'
    when '{{quarter}}' = '2022 Q4' then '2021-10-01'
    when '{{quarter}}' = '2021 Q3' then '2021-07-01'
    end as start_date,
    case
    when '{{quarter}}' = '2022 Q4' then '2023-01-01'
    when '{{quarter}}' = '2022 Q3' then '2022-10-01'
    when '{{quarter}}' = '2022 Q2' then '2022-07-01'
    when '{{quarter}}' = '2022 Q1' then '2022-04-01'
    when '{{quarter}}' = '2021 Q4' then '2022-01-01'
    when '{{quarter}}' = '2021 Q3' then '2021-10-01'
    end as end_date
    ),
    active_address as
    (
    select 'Active Addresses' as metric,
    count(distinct tx_signer) as value
    from near.core.fact_transactions
    where tx_status = 'Success'
    and block_timestamp >= (select start_date from time_frame)
    and block_timestamp >= (select end_date from time_frame)
    ),
    new_address as (
    select 'New Addresses' as metric,
    count(tx_signer) as value
    from (
    select block_timestamp,
    tx_signer,
    row_number() over (partition by tx_signer order by block_timestamp) as rnk
    from near.core.fact_transactions
    )
    Run a query to Download Data