misaghlbTerradash Part 1: Activity - trx
    Updated 2023-04-13
    with transaction_monthly as (
    select date_trunc('week', BLOCK_TIMESTAMP) as block_date,
    count(DISTINCT tx_id) as transaction_count,
    sum(transaction_count) over (order by block_date) as cumu_tx
    from terra.core.fact_transactions
    group by 1
    order by 1
    ),

    transaction_monthly_change as (
    select block_date,
    transaction_count, cumu_tx,
    (transaction_count - lag(transaction_count, 1) over (order by block_date)) / (lag(transaction_count, 1) over (order by block_date)) as change_rate
    from transaction_monthly
    order by block_date
    )

    select block_date, cumu_tx,
    transaction_count,
    (case when change_rate > 50 then 50 else change_rate end) as change_rate
    from transaction_monthly_change
    order by block_date DESC
    Run a query to Download Data