with swap_users as(
SELECT
BLOCK_TIMESTAMP,
ORIGIN_FROM_ADDRESS as user_wallet_address,
'swapping' as EVENT_NAME,
AMOUNT_IN_USD,
AMOUNT_OUT_USD,
PLATFORM,
SYMBOL_IN,
SYMBOL_out,
RANK() OVER (partition by ORIGIN_FROM_ADDRESS order by BLOCK_TIMESTAMP asc)as rank
FROM ethereum.core.ez_dex_swaps
where platform in ('uniswap-v2','uniswap-v3'))
SELECT
sum(AMOUNT_IN_USD) as volume,
count(DISTINCT user_wallet_address) as number,
SYMBOL_IN
FROM swap_users
WHERE rank=1 and amount_in_usd is not null and BLOCK_TIMESTAMP>=current_date-365
GROUP BY SYMBOL_IN