Query editor
/* Success! If you're still running into issues, check out https://dune.com/docs/query/syntax-differences/ or reach out in the #dune-sql Discord channel. */WITH ethereum_idx AS(SELECTstk_in.indexer,'ethereum' as chain,SUM(CAST(stk_in.tokens AS int256) - COALESCE(CAST(stk_out.tokens AS int256), CAST(0 AS int256))) / 1e18 AS balanceFROM thegraph_ethereum.Staking_evt_StakeDeposited AS stk_inLEFT JOIN thegraph_ethereum.Staking_evt_StakeLocked AS stk_outON stk_in.indexer = stk_out.indexerGROUP BY 1,2),arbitrum_idx AS(SELECTstk_in.indexer,'arbitrum' as chain,SUM(CAST(stk_in.tokens AS int256) - COALESCE(CAST(stk_out.tokens AS int256), CAST(0 AS int256))) / 1e18 AS balanceFROM thegraph_arbitrum.Staking_evt_StakeDeposited AS stk_inLEFT JOIN thegraph_arbitrum.Staking_evt_StakeLocked AS stk_outON stk_in.indexer = stk_out.indexerGROUP BY 1,2)selectchain,indexersfrom(SELECTchain,COUNT(*) AS indexersFROM ethereum_idxWHERE balance > 0group by 1union allSELECTchain,COUNT(*) AS indexersFROM arbitrum_idxWHERE balance > 0group by 1) aorder by 1