Arkantransaction 6
    Updated 2022-12-29
    WITH
    table1 as (
    SELECT
    tx_receiver,
    sum(deposit / power(10, 24)) as in_volume
    FROM
    near.core.fact_transfers
    WHERE block_timestamp::date >='2022-01-01'
    GROUP BY 1
    ),
    table2 as (
    SELECT
    TX_SIGNER,
    sum(deposit / power(10, 24)) as out_volume
    FROM
    near.core.fact_transfers
    WHERE block_timestamp::date >='2022-01-01'
    GROUP BY 1
    ),
    table3 as (
    SELECT
    *,
    in_volume - out_volume as net_balance
    FROM
    table1 LEFT OUTER join table2 on tx_signer = tx_receiver
    HAVING net_balance > 0
    ),
    table4 as (
    SELECT
    tx_receiver as user1,
    CASE
    WHEN net_balance < 10 THEN 'Below 10 NEAR'
    WHEN net_balance < 100 THEN 'Between 10 and 100 NEAR'
    WHEN net_balance < 1000 THEN 'Between 100 and 1,000 NEAR'
    WHEN net_balance < 10000 THEN 'Between 1,000 and 10,000 NEAR'
    WHEN net_balance < 100000 THEN 'Between 10,000 and 100,000 NEAR'
    Run a query to Download Data