Query editor
WITH s AS (SELECT *, sum(CASE WHEN scope='Chain-wide search spam' THEN sampled_chain_transactions ELSE 0 END) OVER() AS chain_tx_total, sum(CASE WHEN scope='Chain-wide search spam' THEN sampled_chain_gas_used ELSE 0 END) OVER() AS chain_gas_total, sum(CASE WHEN scope='Chain-wide search spam' THEN sampled_chain_fees_usd ELSE 0 END) OVER() AS chain_fee_total FROM query_8224328) SELECT execution_venue, sum(detected_transactions) AS allocated_search_spam_transactions, 100e0*sum(detected_transactions)/NULLIF(max(chain_tx_total),0) AS share_of_sampled_chain_transactions_pct, sum(gas_used) AS allocated_gas_used, 100e0*sum(gas_used)/NULLIF(max(chain_gas_total),0) AS share_of_sampled_chain_gas_used_pct, sum(fees_usd) AS allocated_fees_usd, 100e0*sum(fees_usd)/NULLIF(max(chain_fee_total),0) AS share_of_sampled_chain_fees_pct, sum(avg_dex_state_queries*detected_transactions)/NULLIF(sum(detected_transactions),0) AS weighted_avg_dex_state_queries FROM s WHERE scope='Identifiable stock-pool search spam' GROUP BY 1 ORDER BY 2 DESC