select
*
from
(
select
blockchain,
swap_size,
sum(frequency) over (
partition by blockchain
order by
swap_size
) * 100 / sum(frequency) over (
partition by blockchain
order by
blockchain
) as frequency,
sum(volume) over (
partition by blockchain
order by
swap_size
) * 100 / sum(volume) over (
partition by blockchain
order by
blockchain
) as volume
from
(
select
blockchain,
round(from_amount_usd,-2) as swap_size,
count(from_amount_usd) as frequency,
sum(from_amount_usd) as volume
from
thorchain.swaps
where
block_timestamp > getdate() - interval '90 days'