binhachonTotal Metamask Users - #3
    Updated 2022-06-24
    with metamask_users as (
    select
    distinct origin_from_address
    from ethereum.core.fact_event_logs
    where contract_address = lower('0x881D40237659C251811CEC9c364ef91dC08D300C')
    ),
    eth_balance as (
    select
    *
    from flipside_prod_db.ethereum.erc20_balances
    where contract_address = 'ETH'
    and balance_date in (select max(balance_date) from flipside_prod_db.ethereum.erc20_balances)
    and user_address in (select origin_from_address from metamask_users)
    )
    select
    case
    when balance < 1 then '1. Less than 1 ETH'
    when balance < 10 then '2. 1 - 10 ETH'
    when balance < 100 then '2. 10 - 100 ETH'
    else '4. Over 100 ETH' end
    as category,
    count(*) as number_of_users,
    100 * ratio_to_report(number_of_users) over () as percentage
    from eth_balance
    group by 1
    Run a query to Download Data