Soheil_MKUntitled Query
    Updated 2023-02-14
    WITH withdraw as (
    select
    BLOCK_TIMESTAMP::date as date,
    TX_SIGNER as wallet,
    sum((DEPOSIT/pow(10,24))) as near_amounts
    from near.core.fact_transfers
    where STATUS='TRUE'
    and DEPOSIT is not null
    group by 1,2
    ),

    deposit as (
    select
    BLOCK_TIMESTAMP::date as date,
    TX_RECEIVER as wallet,
    sum((DEPOSIT/pow(10,24))) as near_amounts
    from near.core.fact_transfers
    where STATUS='TRUE'
    and DEPOSIT is not null
    group by 1,2
    ),


    user_balance as (
    select
    date ,
    wallet ,
    sum (zeroifnull(a.near_amounts) - zeroifnull(b.near_amounts)) balance
    from deposit a
    full outer join withdraw b
    using(wallet,date)
    group by 1,2
    having balance > 0
    ),


    Run a query to Download Data