Sniper2024-04-29 02:20 PM
    Updated 2024-04-29
    with tbl as (SELECT
    trunc(BLOCK_TIMESTAMP,'day') AS date,
    CASE when action = 'delegate' then amount
    when action = 'undelegate' then amount*-1
    -- when action = 'redelegate' then amount*-1
    else amount*-1 end as volume,

    sum(volume/pow(10,6)) AS total_amount
    -- SUM(total_amount) OVER (PARTITION BY date ORDER BY total_amount DESC) AS address_balance,
    -- row_number() OVER (PARTITION BY date ORDER BY total_amount DESC) AS rank
    FROM
    axelar.gov.fact_staking
    WHERE
    action IN ('delegate', 'undelegate')
    GROUP BY 1,2
    )

    select
    sum (total_amount) as balance
    from tbl



    QueryRunArchived: QueryRun has been archived