MLDZMNwoc12
    Updated 2023-02-19
    with tb1 as (select
    distinct RECEIVER as user1,
    sum(AMOUNT/1e6) as total_recieved
    from cosmos.core.fact_transfers
    where TX_SUCCEEDED = 'TRUE' and CURRENCY='uatom'
    and receiver ilike '%cosmos%'
    group by 1),

    tb2 as (select
    distinct SENDER as user2,
    sum(AMOUNT/1e6) as total_sent
    from cosmos.core.fact_transfers s left join tb1 b on s.SENDER=b.user1
    where TX_SUCCEEDED = 'TRUE' and CURRENCY='uatom'
    and SENDER in (select user1 from tb1)
    group by 1),

    tb3 as (select
    distinct user1 as users,
    total_recieved - total_sent as net_atom
    from tb1 s left join tb2 b on s.user1 = b.user2
    where total_recieved>total_sent
    and net_atom>=10000
    )

    select
    PROPOSAL_ID,
    count (distinct voter) as no_voters
    from cosmos.core.fact_governance_votes
    where TX_SUCCEEDED = 'TRUE'
    and voter in (select users from tb3)
    group by 1
    order by 2 DESC
    limit 10
    Run a query to Download Data