with maintable as (
select block_timestamp::date as date,
case when date >= '2022-11-08' then 'During and After FTX & Alameda Collapse'
else 'Before Collapse' end as timespan,
case when abs(amount0_usd) < 10 then 'Less Than $10'
when abs(amount0_usd) >= 10 and abs(amount0_usd) < 100 then '$10 - $100'
when abs(amount0_usd) >= 100 and abs(amount0_usd) < 1000 then '$100 - $1000'
else 'More Than $1000' end as volume_type,
count (distinct tx_hash) as Swaps_Count
from ethereum.uniswapv3.ez_swaps
where block_timestamp >= CURRENT_DATE - 30
group by 1,2,3
order by 1)
select timespan,
volume_type,
avg (swaps_count) as Average_Swaps_Count
from maintable
group by 1,2