Query editor
WITHcontract_stats AS (SELECTCASEWHEN data IS NULL AND value > 0 THEN 'Simple ETH Transfer'ELSE '0' || RIGHT("to"::VARCHAR,-1)END AS "to", COUNT(*) AS num_tx, COUNT(DISTINCT "from") AS unique_addresses, SUM(gas_used) AS total_gas_used, SUM(CASE WHEN NOT success THEN 1.00 ELSE 0.00 END) / COUNT(*) AS revert_rateFROM ethereum."transactions"WHEREblock_time > CURRENT_DATE - '28 days'::INTERVALGROUP BY 1), total_tx_count AS (SELECT SUM(num_tx) AS tatal_tx_count FROM contract_stats)SELECTROW_NUMBER() OVER (ORDER BY cs.num_tx DESC) AS rank, "to", CASE WHEN "to" = 'Simple ETH Transfer' THEN 'N/A' ELSE LEFT("to",6) || '...' || RIGHT("to",5) END AS link_text, CASE WHEN "to" = 'Simple ETH Transfer' THEN 'Simple ETH Transfer' ELSE COALESCE(ann.annotation, t.symbol || ' Token', c.namespace || '-' || c.name) END AS annotation, cs.num_tx, (cs.num_tx::NUMERIC / ttc.tatal_tx_count::NUMERIC)*100 AS share_of_tx, cs.unique_addresses, SUM((cs.num_tx::NUMERIC / ttc.tatal_tx_count::NUMERIC)*100) OVER (ORDER BY cs.num_tx DESCROWS BETWEEN UNBOUNDED PRECEDINGAND CURRENT ROW) AS cumulative_share_of_tx, cs.total_gas_used / 1000000 AS total_gas_used, cs.revert_rate*100 AS revert_rateFROM contract_stats csCROSS JOIN total_tx_count ttcLEFT JOIN dune_user_generated.alex_kroeger_address_annotations ann ON ann.address = CASE WHEN cs."to" = 'Simple ETH Transfer' THEN '\x' ELSE ('\x' || RIGHT("to",-2))::BYTEA ENDLEFT JOIN erc20."tokens" t ON t.contract_address = CASE WHEN cs."to" = 'Simple ETH Transfer' THEN '\x' ELSE ('\x' || RIGHT("to",-2))::BYTEA ENDLEFT JOIN ethereum."contracts" c ON c.address = CASE WHEN cs."to" = 'Simple ETH Transfer' THEN '\x' ELSE ('\x' || RIGHT("to",-2))::BYTEA ENDORDER BY num_tx DESC, annotationLIMIT 100