MLDZMNMBC3
    Updated 2023-01-05
    with tb1 as (select
    TX_TO as user1,
    sum(amount) as total_recieved
    from solana.core.fact_transfers
    where MINT = 'DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263'
    group by 1),

    tb2 as (select
    TX_FROM as user2,
    sum(amount) as total_sent
    from solana.core.fact_transfers
    where MINT = 'DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263'
    group by 1),

    tb3 as (select
    distinct user1 as users,
    total_recieved - total_sent as net_flow
    from tb1 s left join tb2 b on s.user1 = b.user2
    where total_recieved>total_sent

    )

    select
    CASE
    WHEN net_flow < 1000 then 'a. Below 1000'
    WHEN net_flow < 100000 then 'b. 1000 - 100,000'
    WHEN net_flow < 1000000 then 'c. 100,000 - 1,000,000'
    WHEN net_flow < 10000000 then 'd. 1,000,000 - 10,000,000'
    WHEN net_flow >= 10000000 then 'e. Above 10,000,000'
    end as gp,
    count(distinct users) as no_users
    from tb3
    where net_flow>0
    group by 1
    Run a query to Download Data