adriaparcerisasterra Account Activity 2
    Updated 2023-04-13
    with
    activity as (
    SELECT
    distinct tx_sender,
    trunc(block_timestamp,'week') as week,
    count(distinct trunc(block_timestamp,'day')) as counts,
    count(distinct tx_id) as transactions,
    sum(fee) as spent_fee
    from terra.core.fact_transactions where tx_succeeded='TRUE'
    group by 1,2
    ),
    swaps as (
    SELECT
    trunc(block_timestamp,'week') as week,
    trader,
    count(distinct tx_id) as swaps
    from terra.core.ez_swaps
    group by 1,2
    )
    select
    x.week as date,
    case when counts>5 then '+5 active days'
    when counts between 2 and 5 then '2-5 active days'
    else '1 active day' end as type,
    count(distinct trader) as active_swappers,
    sum(active_swappers) over (partition by type order by x.week) as cum_active_swappers,
    sum(swaps) as n_swaps,
    sum(n_swaps) over (partition by type order by x.week) as cum_swaps
    from activity x
    join swaps y on x.week=y.week and tx_sender=trader
    group by 1,2
    order by 1 asc,2
    Run a query to Download Data