John_Galttotal danku luna by the hour
    Updated 2022-04-12
    with table1 as (select
    date_trunc('hour', block_timestamp) as day_hour,
    fl.value:amount / pow(10, 6) as luna_delegated,
    null as luna_undelegated
    from terra.msg_events,
    lateral flatten(input => event_attributes:amount) fl
    where date(block_timestamp) > '2022-02-01'
    and event_type = 'delegate'
    and event_index = 2
    and event_attributes:validator = 'terravaloper12r8929na0amxfj406zw7vk8jmd03fmzcj9r2gg'

    union all

    select
    date_trunc('hour', block_timestamp) as day_hour,
    fl.value:amount / pow(10, 6) as luna_delegated,
    null as luna_undelegated
    from terra.msg_events,
    lateral flatten(input => event_attributes:amount) fl
    where date(block_timestamp) > '2022-02-01'
    and event_type = 'redelegate'
    and event_index = 3
    and event_attributes:destination_validator = 'terravaloper12r8929na0amxfj406zw7vk8jmd03fmzcj9r2gg'

    union all

    select
    date_trunc('hour', block_timestamp) as day_hour,
    null as luna_delagated,
    fl.value:amount / pow(10, 6) as luna_undelegated
    from terra.msg_events,
    lateral flatten(input => event_attributes:amount) fl
    where date(block_timestamp) > '2022-02-01'
    and event_type = 'unbond'
    and event_index = 4
    and event_attributes:validator = 'terravaloper12r8929na0amxfj406zw7vk8jmd03fmzcj9r2gg'