WITH SWAPS AS (
select swapper as wallet,
count(distinct tx_group_id) as swaps,
PERCENT_RANK() OVER(ORDER BY swaps desc) AS Percent_Rank
from algorand.swaps
where block_timestamp >= '2022-01-01'
and swap_from_amount >= 0
group by wallet--, type
order by swaps desc
)
select count(distinct wallet) as total_wallets,
sum(swaps) as total_swaps,
avg(swaps),
max(swaps),
median(swaps),
min(swaps)
from SWAPS