MLDZMNBTB11
    Updated 2023-02-01
    with t1 as (select
    tx_sender,
    min(block_timestamp) as first_txn,
    count(date_trunc('day',block_timestamp)) as active_weeks
    from terra.core.fact_transactions
    group by 1
    ),

    t2 as (select
    distinct tx_sender
    from t1 where active_weeks>{{Active_weeks}}
    )

    select
    date_trunc('week',block_timestamp) as date,
    case
    when tx_sender in (select tx_sender from t2) then 'Active wallets' else 'Regular wallets'
    end as gp,
    sum(FEE) as total_paid_fee,
    avg(fee) as average_fee,
    median(fee) as median_fee,
    count(distinct tx_sender) as no_wl
    from terra.core.fact_transactions
    group by 1,2
    Run a query to Download Data