MadiUntitled Query
    Updated 2022-12-14
    with df as ((SELECT
    date_trunc ('week',block_timestamp) as date,
    action,
    count (distinct TX_ID) as TX_Count,
    sum (amount) as Volume
    FROM terra.core.ez_staking
    WHERE action = 'Delegate' and date >= CURRENT_DATE - 180 and TX_SUCCEEDED = 'TRUE'
    group by 1,2
    order by 1)

    UNION ALL

    (SELECT
    date_trunc ('week',block_timestamp) as date,
    action,
    count (distinct TX_ID)*(-1) as TX_Count,
    sum (amount)*(-1) as Volume
    FROM terra.core.ez_staking
    WHERE action = 'Undelegate' and date date >= CURRENT_DATE - 180 and TX_SUCCEEDED = 'TRUE'
    group by 1,2
    order by 1))

    select date, sum(volume) over (order by date) as Cumualtive from(
    select date, sum (Volume) as volume --sum(Volume)*100/1047120273 as percstack
    from df group by 1)
    Run a query to Download Data