lagandispenserCopy of Untitled Query
    Updated 2022-06-28
    with inflow as (
    select
    to_address as wallet,
    sum(rune_amount) as rune_amount
    from flipside_prod_db.thorchain.transfers
    where asset = 'THOR.RUNE'
    group by 1
    ),
    out_flow as (
    select
    from_address as wallet,
    sum(rune_amount) as rune_amount
    from flipside_prod_db.thorchain.transfers
    where asset = 'THOR.RUNE'
    group by 1
    ),
    common_wallets as (
    select wallet ,
    (inflow.rune_amount - out_flow.rune_amount) as rune_amount
    from inflow join out_flow using (wallet)
    where inflow.rune_amount - out_flow.rune_amount >=0
    group by 1,2
    ),
    all_ as (
    select wallet ,rune_amount from common_wallets
    UNION
    select wallet , rune_amount from inflow
    where wallet not in (select wallet from out_flow )
    )
    select case when rune_amount BETWEEN 0 and 1 then '0-1'
    when rune_amount BETWEEN 1 and 10 then '1-10'
    when rune_amount BETWEEN 10 and 100 then '10-100'
    when rune_amount BETWEEN 100 and 500 then '100-500'
    when rune_amount BETWEEN 500 and 1000 then '500-1K'
    when rune_amount BETWEEN 1000 and 10000 then '1K-10K'
    Run a query to Download Data