jackguyNEAR Distribution 2 copy
    Updated 2023-03-13
    WITH tab10 as (
    SELECT
    signer_id,
    min(date_trunc('day', block_timestamp)) as first_day,
    count(DISTINCT tx_hash) as profile_change_events
    FROM near.social.fact_addkey_events
    GROUP BY 1
    ), tab1 as (
    SELECT
    tx_receiver,
    sum(deposit / power(10, 24)) as in_volume
    FROM near.core.fact_transfers
    GROUP BY 1
    ), tab2 as (
    SELECT
    TX_SIGNER,
    sum(deposit / power(10, 24)) as out_volume
    FROM near.core.fact_transfers
    GROUP BY 1
    ), tab3 as (
    SELECT
    *,
    in_volume - out_volume as net_balance
    FROM tab1
    LEFT OUTER join tab2
    on tx_signer = tx_receiver
    WHERE TX_SIGNER in (
    SELECT
    DISTINCT signer_id
    FROM tab10
    WHERE first_day BETWEEN '{{ user_group_first_day }}' AND '{{ user_group_last_day }}'
    )
    HAVING net_balance > 0
    )

    SELECT
    Run a query to Download Data