keshanCopy of Delegator Decentralisation (Gini) for LUNA/UST
    Updated 2022-03-15
    -- Original : https://app.flipsidecrypto.com/velocity/queries/2aa90898-9bfd-4e5e-a5d3-87c37fe32019
    -- by JamesBall

    WITH

    delegator_voting_power AS (
    SELECT
    address,
    date_trunc('day',block_timestamp) as date,
    voting_power
    FROM terra.validator_voting_power
    group BY
    date,
    address,
    voting_power
    order by date
    ),

    ranked_voting_power as (
    select
    address,
    date,
    voting_power,
    row_number() OVER (PARTITION BY date ORDER BY voting_power DESC) as ranking
    FROM delegator_voting_power
    group BY
    date,
    address,
    voting_power
    order by date
    )


    select
    date,
    sum(voting_power) as total_voting_power,