JonasoFLOW : trader : 30D
    Updated 2024-09-05
    with

    A as(
    select trader, sum(case when amount_out_usd is not null then amount_out_usd else amount_in_usd end) as volume
    from flow.defi.ez_dex_swaps
    where block_timestamp >= current_date - interval '30 days'
    group by 1),

    B as(
    select trader, min(block_timestamp) as block_timestamp
    from flow.defi.ez_dex_swaps
    group by 1
    having min(block_timestamp) >= current_date - interval '30 days' )

    select
    case when b.trader is not null then 'new traders' else 'pre traders' end as trader,
    sum(volume) as volume,
    count(a.trader) as number
    from A as a
    left join B as b on a.trader = b.trader
    group by 1




    QueryRunArchived: QueryRun has been archived