Ali3NDistribution of "ReDelegate From" Users By Their Volume of Actions SG-1 vs GAME
    Updated 2022-12-11
    with delegatet as (
    select tx_id,
    case when attribute_value = 'cosmosvaloper196ax4vc0lwpxndu9dyhvca7jhxp70rmcvrj90c' then 'SG-1'
    else 'Game' end as validator_name
    from cosmos.core.fact_msg_attributes
    where msg_type = 'delegate'
    and attribute_key = 'validator'
    and ATTRIBUTE_VALUE in ('cosmosvaloper196ax4vc0lwpxndu9dyhvca7jhxp70rmcvrj90c','cosmosvaloper1qaa9zej9a0ge3ugpx3pxyx602lxh3ztqgfnp42')
    and tx_succeeded = 'TRUE'),

    delegateamount as (
    select tx_id,
    block_timestamp,
    split(ATTRIBUTE_VALUE,'uatom')[0]::numeric/1e6 as Delegate_Amount
    from cosmos.core.fact_msg_attributes
    where msg_type = 'delegate'
    and attribute_key = 'amount'
    and tx_id in (select tx_id from delegatet)),

    delegatort as (
    select tx_id,
    block_timestamp,
    attribute_value as Delegator
    from cosmos.core.fact_msg_attributes
    where msg_type = 'coin_spent'
    and attribute_index = '0'
    and attribute_key = 'spender'
    and msg_index = '0'
    and tx_id in (select tx_id from delegatet)),

    maindelegate as (
    select t1.tx_id,
    t2.block_timestamp,
    delegator,
    delegate_amount,
    validator_name
    Run a query to Download Data