Updated 2023-01-04
    with table_1 as ( select *
    from osmosis.core.fact_swaps, table(flatten(input => pool_ids))
    where tx_status = 'SUCCEEDED'
    and block_timestamp >= current_date - 90),

    table_2 as (select date_trunc('day', block_timestamp) as day, count(distinct(tx_id)) as swap_count, sum(swap_count) over (order by day) as cumu_swap_count,
    count(distinct(trader)) as swapper_count, swap_count/swapper_count as avg_swap
    from table_1
    group by 1)

    select *
    from table_2
    order by 1 desc