misaghlbTerradash Part 1: Activity - trx
    Updated 2023-04-13
    with users_transaction as (
    select TX_SENDER as account, BLOCK_TIMESTAMP
    from terra.core.fact_transactions
    ),

    new_users_date as (
    select account,
    min(BLOCK_TIMESTAMP) as min_block_time
    from users_transaction
    group by account
    order by 2
    ),

    new_users_monthly as (
    select date_trunc('week', min_block_time) as block_date,
    count(distinct account) as new_users_count,
    sum(new_users_count) over (order by block_date) as cumu_users
    from new_users_date
    group by 1
    order by 1
    ),

    new_users_monthly_change as (
    select block_date, cumu_users,
    new_users_count,
    (new_users_count - lag(new_users_count, 1) over (order by block_date)) / (lag(new_users_count, 1) over (order by block_date)) as change_rate
    from new_users_monthly
    order by block_date
    )

    select block_date,
    new_users_count, cumu_users,
    (case when change_rate > 50 then 50 else change_rate end) as change_rate -- Do some normalize
    from new_users_monthly_change
    order by block_date DESC
    Run a query to Download Data