John_Galttotal gen rewards claimed - shows that boot + lock misses some
    Updated 2022-04-26
    with normal1 as (select
    case
    when event_attributes:from = 'terra1hncazf652xa0gpcwupxfj6k4kl4k4qg64yzjyf' then event_attributes:to
    when event_attributes:"0_from" = 'terra1hncazf652xa0gpcwupxfj6k4kl4k4qg64yzjyf' then event_attributes:"0_to"
    when event_attributes:"1_from" = 'terra1hncazf652xa0gpcwupxfj6k4kl4k4qg64yzjyf' then event_attributes:"1_to"
    when event_attributes:"2_from" = 'terra1hncazf652xa0gpcwupxfj6k4kl4k4qg64yzjyf' then event_attributes:"2_to"
    when event_attributes:"3_from" = 'terra1hncazf652xa0gpcwupxfj6k4kl4k4qg64yzjyf' then event_attributes:"3_to"
    when event_attributes:"4_from" = 'terra1hncazf652xa0gpcwupxfj6k4kl4k4qg64yzjyf' then event_attributes:"4_to"
    end as address,
    sum(event_attributes:claimed_amount) / pow(10, 6) as claimed
    from terra.msg_events
    where date(block_timestamp) > '2021-12-01'
    and
    ((event_attributes:"0_contract_address" = 'terra1hncazf652xa0gpcwupxfj6k4kl4k4qg64yzjyf' and event_attributes:"0_action" = 'claim') or
    (event_attributes:"1_contract_address" = 'terra1hncazf652xa0gpcwupxfj6k4kl4k4qg64yzjyf' and event_attributes:"1_action" = 'claim') or
    (event_attributes:"2_contract_address" = 'terra1hncazf652xa0gpcwupxfj6k4kl4k4qg64yzjyf' and event_attributes:"2_action" = 'claim') or
    (event_attributes:"3_contract_address" = 'terra1hncazf652xa0gpcwupxfj6k4kl4k4qg64yzjyf' and event_attributes:"3_action" = 'claim') or
    (event_attributes:"4_contract_address" = 'terra1hncazf652xa0gpcwupxfj6k4kl4k4qg64yzjyf' and event_attributes:"4_action" = 'claim') or
    (event_attributes:"5_contract_address" = 'terra1hncazf652xa0gpcwupxfj6k4kl4k4qg64yzjyf' and event_attributes:"5_action" = 'claim') or
    (event_attributes:"6_contract_address" = 'terra1hncazf652xa0gpcwupxfj6k4kl4k4qg64yzjyf' and event_attributes:"6_action" = 'claim') or
    (event_attributes:"7_contract_address" = 'terra1hncazf652xa0gpcwupxfj6k4kl4k4qg64yzjyf' and event_attributes:"7_action" = 'claim') or
    (event_attributes:"8_contract_address" = 'terra1hncazf652xa0gpcwupxfj6k4kl4k4qg64yzjyf' and event_attributes:"8_action" = 'claim') or
    (event_attributes:"9_contract_address" = 'terra1hncazf652xa0gpcwupxfj6k4kl4k4qg64yzjyf' and event_attributes:"9_action" = 'claim') or
    (event_attributes:"10_contract_address" = 'terra1hncazf652xa0gpcwupxfj6k4kl4k4qg64yzjyf' and event_attributes:"10_action" = 'claim'))
    and event_index = 3
    group by address
    ),

    normal_final as (select row_number() over (order by claimed desc) as Rank, address, claimed
    from normal1
    where address <> 'terra1627ldjvxatt54ydd3ns6xaxtd68a2vtyu7kakj'
    and address <> 'terra1tvld5k6pus2yh7pcu7xuwyjedn7mjxfkkkjjap'
    ),

    lock1 as (select
    case