flyingfishSleepy - Near Delegators pt2
    Updated 2023-07-04
    with delegators_raw as(
    select
    address,
    signer_id,
    max(action_type) max_action,
    count(1) actions_count
    from(
    select address,
    signer_id,
    tx_hash,
    action,
    case when action = 'staking' then 0
    when action = 'unstaking' then 1
    end action_type
    from near.core.fact_staking_actions
    where action in ('staking', 'unstaking')
    and signer_id = 'binancecold3.near'
    )
    group by address, signer_id
    having max_action = 0
    )
    select
    address,
    count(distinct signer_id) delegators
    from delegators_raw
    group by address
    order by delegators desc

    Run a query to Download Data