Query editor
withsummary as (selectcasewhen wealth_rank = 1 then '[1] 10M+'when wealth_rank = 2 then '[2] 10M'when wealth_rank = 3 then '[3] 1M'when wealth_rank = 4 then '[4] 100K'when wealth_rank = 5 then '[5] 10K'when wealth_rank = 6 then '[6] 1k'end as wealth_rank,penguin_indentification,cast(count(*) as double) as population,sum(claimed_amount) as claimed,sum(sold_amount) as sold,sum(hold_amount) as hold,sum(sold_amount) / sum(claimed_amount) as pct_sold,sum(hold_amount) / sum(claimed_amount) as pct_holdfromquery_4446924group by1,2)selectwealth_rank,penguin_indentification,population,population/(select sum(population) from summary) as pct_population,sum(population) over (order by wealth_rank desc) as total_population,claimed as allocation,claimed/(select sum(claimed) from summary) as pct_allocation,sum(claimed) over (order by wealth_rank desc) as total_wealth,hold,sold,pct_sold,pct_holdfrom summaryorder by 1 desc