Abbas_ra21cosmos #3
    Updated 2022-12-14
    with tb1 AS (select
    TX_ID,
    BLOCK_TIMESTAMP,
    label AS "destination validator name",
    ATTRIBUTE_VALUE AS "destination validator Address"
    from
    cosmos.core.fact_msg_attributes inner join cosmos.core.fact_validators on Address=ATTRIBUTE_VALUE
    where MSG_TYPE='redelegate' and ATTRIBUTE_KEY='destination_validator'),
    tb2 AS (select
    TX_ID,
    BLOCK_TIMESTAMP,
    label AS "source validator name",
    ATTRIBUTE_VALUE AS "source validator Address"
    from
    cosmos.core.fact_msg_attributes inner join cosmos.core.fact_validators on Address=ATTRIBUTE_VALUE
    where MSG_TYPE='redelegate' and ATTRIBUTE_KEY='source_validator'),
    tb3 AS (select
    TX_ID,
    BLOCK_TIMESTAMP,
    split(attribute_value,'uatom')[0]::numeric / pow(10,6) AS "amount"
    from
    cosmos.core.fact_msg_attributes
    where MSG_TYPE='redelegate' and ATTRIBUTE_KEY='amount'),
    tb4 AS (
    select
    TX_ID,
    BLOCK_TIMESTAMP,
    attribute_value AS "user Address"
    from
    cosmos.core.fact_msg_attributes
    where MSG_TYPE='message' and ATTRIBUTE_KEY='sender'
    ),
    main AS (select
    distinct A.TX_ID,
    A.BLOCK_TIMESTAMP,
    "user Address",
    Run a query to Download Data