Abolfazl_771025total flow holders
    Updated 2022-11-29
    with flow_in as (select
    event_data:to as user,
    sum(event_data:amount) as "volume in (Flow)"
    from flow.core.fact_events
    where event_type = 'TokensDeposited'
    and tx_succeeded = 'TRUE'
    and event_contract = 'A.1654653399040a61.FlowToken'
    group by 1
    ),flow_out as (select
    event_data:from as user,
    sum(event_data:amount) as "volume out (Flow)"
    from flow.core.fact_events
    where event_type = 'TokensWithdrawn'
    and tx_succeeded = 'TRUE'
    and event_contract = 'A.1654653399040a61.FlowToken'
    group by 1
    ) , main as (select
    distinct a.user "holders",
    sum("volume in (Flow)" - "volume out (Flow)") as "volume of flow that hold"
    from flow_in a join flow_out b on a.user = b.user
    full outer join flow.core.dim_contract_labels c on a.user = c.account_address
    where a.user is not null
    and a.user != 'null'
    group by 1)
    select
    count("holders") as "total holders count",
    sum("volume of flow that hold") as "total hold volume (Flow)",
    min("volume of flow that hold") as "minimum hold volume (Flow)",
    avg("volume of flow that hold") as "average hold volume (Flow)",
    max("volume of flow that hold") as "maximum hold volume (Flow)"
    from main
    where "volume of flow that hold" > 0
    Run a query to Download Data