crypto_gostuers who are currently staking range
    Updated 2024-11-17
    with stakers as (
    select
    signer_id as user,
    sum(amount) as total_staked
    from
    near.gov.fact_staking_actions
    where
    action = 'staking' -- Only include staking actions
    group by
    signer_id
    )

    select
    case
    when total_staked > 10 and total_staked <= 50 then '10-50 NEAR'
    when total_staked > 50 and total_staked <= 100 then '50-100 NEAR'
    when total_staked > 100 and total_staked <= 150 then '100-150 NEAR'
    end as "stake_range",
    count(distinct user) as user_count
    from stakers
    where user not in ( -- Exclude users who have unstaked or withdrawn
    select signer_id
    from near.gov.fact_staking_actions
    where action in ('unstaking', 'withdrawal')
    )
    group by "stake_range"
    having "stake_range" is not null -- Ensure we only return valid ranges
    order by "stake_range";
    QueryRunArchived: QueryRun has been archived