Moesqsq tot 2
    Updated 2023-02-15
    select
    sum(USD_AMOUNT ) as USD_AMOUNT,
    avg(avg_USD_AMOUNT ) as avg_USD_AMOUNT,
    sum(senders ) as senders,
    sum(txns ) as txns
    from (
    (SELECT
    'Ethereum' as source,
    sum(AMOUNT_USD) as USD_AMOUNT,
    avg(AMOUNT_USD) as avg_USD_AMOUNT,
    count (distinct DECODED_LOG:refundAddress) as senders,
    count(distinct l.TX_HASH) as txns
    FROM ethereum.core.fact_decoded_event_logs l
    inner join ethereum.core.ez_token_transfers t on t.tx_hash = l.tx_hash
    WHERE l.tx_hash in (
    SELECT tx_hash
    FROM ethereum.core.fact_token_transfers
    WHERE to_address ILIKE ('0xce16f69375520ab01377ce7b88f5ba8c48f8d666')
    )

    and DECODED_LOG:destinationChain is not null
    )

    union all


    (with base as (SELECT
    'Polygon' as source
    ,*,
    try_hex_decode_string(substr(data, 3 + (64*7), 16)) as destination,
    concat (source,'->',destination) as direction
    FROM polygon.core.fact_event_logs
    Run a query to Download Data