Query editor
-- AX1 Wallet Wars leaderboard.-- Base model: query_7703964.-- Parameters: days_back, chain, wallet_group, fee_rate.WITH params AS (SELECTLOWER('all') AS chain_filter,LOWER('all') AS wallet_group_filter),filtered AS (SELECT *FROM query_7703964CROSS JOIN params pWHERE day >= CURRENT_TIMESTAMP - INTERVAL '30' DAYAND (p.chain_filter = 'all' OR chain_scope = p.chain_filter)AND (p.wallet_group_filter = 'all' OR wallet_group = p.wallet_group_filter)),summary AS (SELECTwallet_name,wallet_group,SUM(swap_volume_usd) AS swap_volume_usd,SUM(swap_txs) AS swap_txs,SUM(active_users) AS active_user_days,SUM(revenue_proxy_usd) AS revenue_proxy_usd,SUM(growth_events) AS growth_events,ARRAY_JOIN(ARRAY_AGG(DISTINCT source_kind), ', ') AS source_mix,ARRAY_JOIN(ARRAY_AGG(DISTINCT source_name), ' | ') AS source_names,ARRAY_JOIN(ARRAY_AGG(DISTINCT notes), ' | ') AS coverage_notesFROM filteredGROUP BY 1, 2)SELECTROW_NUMBER() OVER (ORDER BY swap_volume_usd DESC, revenue_proxy_usd DESC, growth_events DESC, wallet_name) AS rank,wallet_name,wallet_group,ROUND(COALESCE(swap_volume_usd, 0), 2) AS swap_volume_usd,COALESCE(swap_txs, 0) AS swap_txs,COALESCE(active_user_days, 0) AS active_user_days,ROUND(COALESCE(revenue_proxy_usd, 0), 2) AS revenue_proxy_usd,COALESCE(growth_events, 0) AS growth_events,ROUND(COALESCE(swap_volume_usd, 0) / NULLIF(SUM(swap_volume_usd) OVER (), 0),4) AS swap_volume_share,source_mix,coverage_notesFROM summaryORDER BY rank;