binhachon18. [Easy] Wealth distribution - Base table - Percentile
    Updated 2021-11-07
    with wealth_distribution as(
    select address, sum(amount) as balance from (
    select from_address as address, -rune_amount as amount from thorchain.transfers
    union all
    select to_address as address, rune_amount as amount from thorchain.transfers
    )
    group by address
    )
    select percentile_25, percentile_50, percentile_75 from (
    select '1' as symbol, percentile_cont(0.25) within group (order by balance) as percentile_25,
    percentile_cont(0.5) within group (order by balance) as percentile_50,
    percentile_cont(0.75) within group (order by balance) as percentile_75
    from wealth_distribution
    where balance > 0
    group by symbol
    )



    Run a query to Download Data