MetaLightTOKE Wallet Metrics
    Updated 2024-08-06
    -- forked from jimmysand / mpb1 @ https://flipsidecrypto.xyz/jimmysand/q/f9y1n3Gt103q/mpb1

    with tb1 as (select
    TX_TO as user1,
    sum(amount) as total_recieved
    from solana.core.fact_transfers
    where MINT = 'AmgUMQeqW8H74trc8UkKjzZWtxBdpS496wh4GLy2mCpo'
    group by 1),

    tb2 as (select
    TX_FROM as user2,
    sum(amount) as total_sent
    from solana.core.fact_transfers
    where MINT = 'AmgUMQeqW8H74trc8UkKjzZWtxBdpS496wh4GLy2mCpo'
    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
    count(distinct users) as total_holders,
    sum(net_flow) as total_hold_flow,
    avg(net_flow) as average_hold_flow
    from tb3 s


    QueryRunArchived: QueryRun has been archived