Updated 2024-10-05
    with main as (
    select
    tx_hash,
    block_timestamp,
    tx_signer as user,
    transaction_fee/1e24 as tx_fee
    from near.core.fact_transactions
    where tx_succeeded = 1
    and block_timestamp::date between '{{ start_date }}' and '{{ end_date }}'
    )

    select
    count(distinct tx_hash) as transactions,
    (transactions / (select count(distinct tx_hash) from near.core.fact_transactions where block_timestamp::date between '{{ start_date }}' and '{{ end_date }}')) * 100 as success_rate,
    count(distinct user) as users,
    sum(tx_fee) as fees_volume_near,
    avg(tx_fee) as average_fees_amount_near,
    transactions / count(distinct block_timestamp::date) as daily_average_transactions,
    users / count(distinct block_timestamp::date) as daily_average_users
    from main
    QueryRunArchived: QueryRun has been archived