with maintable as (
select block_timestamp::date as date,
pool_name,
count (distinct tx_hash) as Swaps_Count,
count (distinct recipient) as Swappers_Count,
abs (sum (amount0_usd)) as Total_Volume,
abs (avg (amount0_usd)) as Average_Volume
from ethereum.uniswapv3.ez_swaps
where block_timestamp >= CURRENT_DATE - 30
group by 1,2 having Total_Volume > 0),
finaltable as (
select *,
row_number() over (partition by date order by Total_Volume desc) as RN
from maintable)
select * from finaltable
where RN <= 10
order by date