freemartianRedelegate Reason
    Updated 2022-07-19
    with top_rewarding_validators as (
    select validator_address as va, sum(amount)/pow(10,6) as reward_value
    from osmosis.core.fact_staking_rewards
    where action = 'withdraw_rewards'
    and block_timestamp > '2022-01-01'
    group by validator_address
    order by reward_value DESC
    limit 10),

    undelegation as (
    select
    delegator_address,
    min(completion_time) as osmo_receive_time
    from osmosis.core.fact_staking
    where action = 'undelegate'
    and block_timestamp > '2022-01-01'
    group by delegator_address
    ),

    next_transactions as (
    select tx_from, tx_id, block_timestamp
    from osmosis.core.fact_transactions t
    inner join undelegation u on u.delegator_address = t.tx_from
    where t.block_timestamp > u.osmo_receive_time
    ),

    first_move as (
    select tx_from, tx_id, min(block_timestamp)
    from next_transactions
    group by tx_from, tx_id
    ),

    top_redelegate_validators as (
    select count(distinct fm.tx_id) as count, VALIDATOR_ADDRESS
    from osmosis.core.fact_staking m
    inner join first_move fm on fm.tx_id = m.tx_id
    Run a query to Download Data