John_GaltAddresses that have unpledged, by the number of unpledge events
    Updated 2022-03-20
    with table1 as (select ----- this is all unpledge events, by address and date
    block_timestamp as date,
    event_attributes:to::string as unpledger_address,
    event_attributes:unbond / pow(10, 6) as xprism_unpledged
    from terra.msg_events
    where event_index = 3
    and event_attributes:"1_action" = 'privileged_refresh_boost'
    and event_attributes:"0_contract_address" = 'terra1pa4amk66q8punljptzmmftf6ylq3ezyzx6kl9m'
    and event_attributes:"1_contract_address" = 'terra1042wzrwg2uk6jqxjm34ysqquyr9esdgm5qyswz'
    order by date
    ),

    table2 as (select
    unpledger_address, count(unpledger_address) as number_of_unpledge_events
    from table1
    group by unpledger_address
    having count(unpledger_address) > 0
    order by number_of_unpledge_events
    ),

    one_unpledge_table as (select
    table1.date, table1.unpledger_address
    from table1
    inner join table2 on table1.unpledger_address = table2.unpledger_address where number_of_unpledge_events = 1
    ),

    two_unpledge_table as (select
    table1.date, table1.unpledger_address
    from table1
    inner join table2 on table1.unpledger_address = table2.unpledger_address where number_of_unpledge_events = 2
    ),

    three_unpledge_table as (select
    table1.date, table1.unpledger_address
    from table1
    inner join table2 on table1.unpledger_address = table2.unpledger_address where number_of_unpledge_events = 3
    Run a query to Download Data