MostlyData_Solana Stats - Fee vs time (global)
    Updated 2025-03-10
    -- forked from Solana Stats - Fee rewards distribution vs time @ https://flipsidecrypto.xyz/studio/queries/02fadac4-c64d-41dc-9d25-3a4634a83263

    with date_filter as (
    select
    case
    when '{{n_days}}' != 0 then current_date() - interval '{{n_days}} days'
    else cast('{{start_date}}' as timestamp)
    end as start_date,
    case
    when '{{n_days}}' != 0 then current_date()
    else cast('{{end_date}}' as timestamp)
    end as end_date
    )

    ,txs_info as(
    select
    rf.tx_id,
    date_trunc('hour',rf.block_timestamp) as dt,
    rf.fee * pow(10,-9) as fee

    from solana.core.fact_transactions rf
    join date_filter df
    on rf.block_timestamp between df.start_date and df.end_date
    )

    ,group_fee_rewards as(
    select
    dt,
    percentile_cont(0.25) within group (order by fee) as p25,
    percentile_cont(0.5) within group (order by fee) as p50,
    percentile_cont(0.95) within group (order by fee) as p95

    from txs_info
    group by dt
    QueryRunArchived: QueryRun has been archived