headitmanager$RUNE users before 2021-09-01
    Updated 2022-06-19
    with wallet_in as (select sum(rune_amount) as in_amount,to_address from thorchain.transfers
    where asset='THOR.RUNE' and block_timestamp::date < '2021-09-01' group by to_address )
    ,wallet_out as (select sum(rune_amount) as out_amount ,from_address from thorchain.transfers where asset='THOR.RUNE'
    AND NOT to_address = 'thor1g98cy3n9mmjrpn0sxmn63lztelera37n8n67c0' and block_timestamp::date < '2021-09-01' group by from_address )

    ,lp_in as(select sum(rune_amount) as lp_in_amount,from_address from thorchain.liquidity_actions
    where lp_action='add_liquidity' and block_timestamp::date < '2021-09-01' group by from_address)
    ,lp_out as (select sum(rune_amount) as lp_out_amount,from_address from thorchain.liquidity_actions
    where lp_action='remove_liquidity' and block_timestamp::date < '2021-09-01' group by from_address)


    ,holdings as (select (zeroifnull(in_amount-out_amount) + zeroifnull(lp_in_amount-lp_out_amount)) as rune_holdings ,to_address from wallet_in full outer join wallet_out
    on to_address=wallet_out.from_address
    full outer join lp_in
    on to_address=lp_in.from_address
    full outer join lp_out
    on to_address=lp_out.from_address)

    select sum(rune_holdings),avg(rune_holdings),count(distinct to_address) from holdings where rune_holdings>0
    Run a query to Download Data