Query editor
WITH entity_net AS (SELECTCASEWHEN entity IS NULL OR TRIM(entity) = '' THEN 'Unlabeled'ELSE entityEND AS entity,SUM(amount_staked - COALESCE(amount_full_withdrawn, 0) - COALESCE(amount_partial_withdrawn, 0)) AS net_staked_ethFROM staking_ethereum.flowsGROUP BY 1),ranked AS (SELECTentity,net_staked_eth,ROW_NUMBER() OVER (ORDER BY net_staked_eth DESC) AS rn,SUM(net_staked_eth) OVER () AS total_ethFROM entity_netWHERE net_staked_eth > 0),collapsed AS (SELECTCASE WHEN rn <= 10 THEN entity ELSE 'Others' END AS entity_group,SUM(net_staked_eth) AS net_staked_eth,MAX(total_eth) AS total_ethFROM rankedGROUP BY 1)SELECTentity_group AS entity,net_staked_eth,100.0 * net_staked_eth / NULLIF(total_eth, 0) AS share_pctFROM collapsedORDER BY net_staked_eth DESC