select day, pool_name, case when sum(swap_volume) over (partition by day order by day) = 0 then 0 else 100 * swap_volume / sum(swap_volume) over (partition by day order by day) end as percentage from (
select day, pool_name, coalesce(sum(swap_volume_rune_usd),0) as swap_volume from thorchain.daily_pool_stats
group by day, pool_name
)
where day > getdate() - INTERVAL'1 month'
order by day desc, percentage asc