amirozarune balance
    Updated 2022-06-24
    with receive as (
    select to_address, sum(rune_amount) as received
    from thorchain.transfers
    group by 1),
    send as (select from_address, sum(rune_amount) as sent
    from thorchain.transfers
    where from_address in (select to_address from receive)
    group by 1),

    total as (select a.to_address, (a.received - b.sent) as total_rune
    from receive a
    left outer join send b on a.to_address = b.from_address)
    select total_rune --count(distinct to_address)from total
    where total_rune>0