hessDaily Transactions by New Vs. Active Users
    Updated 2023-04-19
    with transactions as ( select tx_sender, count(DISTINCT(block_timestamp::date)) as active_day
    from terra.core.fact_transactions
    where block_timestamp >= current_date - 180
    group by 1
    having active_day > 14
    )
    ,
    new_user as ( select tx_sender, min(block_timestamp) as date
    from terra.core.fact_transactions
    group by 1
    )
    ,
    new as ( select date, tx_sender
    from new_user
    where date >= '2023-01-01')
    ,
    final as ( select 'Active Users' as type, tx_sender , date(block_timestamp) as date,
    count(DISTINCT(tx_id)) as total_tx, sum(fee) as total_fee_in_luna
    from terra.core.fact_transactions
    where tx_sender in (select tx_sender from transactions)
    and block_timestamp >= '2023-01-01'
    group by 1,2,3
    UNION
    select 'New Users' as type, tx_sender , date(block_timestamp) as date,
    count(DISTINCT(tx_id)) as total_tx, sum(fee) as total_fee_in_luna
    from terra.core.fact_transactions
    where tx_sender in (select tx_sender from new)
    and block_timestamp >= '2023-01-01'
    group by 1,2,3)

    select type, date, avg(total_tx) as avg_tx, avg(total_fee_in_luna) as avg_fee, sum(total_tx) as total_transactions,
    sum(total_fee_in_luna) as fee_in_luna
    from final
    group by 1,2

    Run a query to Download Data