MLDZMNwoc10
    Updated 2023-02-18
    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
    ),

    tb4 as (select
    voter,
    case when voter in (select users from tb3) then 'Whales' else 'Ordinary users' end as user_type,
    count(tx_id) as vote_count
    from cosmos.core.fact_governance_votes
    where TX_SUCCEEDED = 'TRUE'
    group by 1,2)

    select
    user_type,
    case
    when vote_count<5 then 'under 5 votes'
    Run a query to Download Data