jackguynear_balance 3
    Updated 2023-04-04
    WITH tab1 as (
    SELECT
    date_trunc('day', block_timestamp) as day,
    'tx_out' as tx_type,
    sum(deposit / power(10, 24)) as near_amt
    FROM near.core.fact_transfers
    WHERE tx_signer IN ('79501b068d4fcbbcea3e7c332891a7d8abfd9864657b9c2cc3c18c944b1db558', '12da367348f40c3dec5b919c49b61bf4eb67544674e71edbe93dcbaded3819ea', '869554f6594f866d1aeae1c07d4687ebf8e421d6ef69c460b48ce0b33733eebf', '38b445487678a1173fba0e09fd346f3ecb66db858cb399d7637d7618868f9f03', 'd1cba12439c2fa4e0b55ae880b830de415e70ccee22fc7e4cd2493d9a871bace')
    --AND tx_receiver LIKE 'bulksender.near'
    GROUP BY 1,2
    ), tab2 as (
    SELECT
    date_trunc('day', block_timestamp) as day,
    'tx_in' as tx_type,
    sum(deposit / power(10, 24)) as near_amt
    FROM near.core.fact_transfers
    WHERE tx_receiver LIKE 'metricsdao.multisafe.near'
    GROUP BY 1,2
    )


    SELECT
    day,
    sum(CASE WHEN tx_type LIKE 'tx_in' THEN near_amt END) as near_inflow,
    sum(CASE WHEN tx_type LIKE 'tx_out' THEN near_amt END) as near_outflow
    from (
    SELECT *
    from tab1

    UNION

    SELECT *
    FROM tab2
    ) GROUP BY 1

    Run a query to Download Data