Query editor
-- ============================================================================-- Section 3: Chain Rankings-- ============================================================================-- Produces 4 ranking views in one result set, discriminated by rank_type:-- 'supply' -> Top Chains by Supply (with Market Share %)-- 'inflow' -> Top Chains by Inflow-- 'outflow' -> Top Chains by Outflow-- 'net_flow' -> Top Chains by Net Flow (signed, so "top" includes-- most-negative at the bottom when sorted ascending by rank)---- Dashboard should filter WHERE rank_type = 'x' per tile, or this can be-- split into 4 separate queries later if the dashboard tool needs that.-- ============================================================================WITH base_data AS (SELECT * FROM query_7839093 -- chain, current_supply, inflow_35d, outflow_35d, net_flow_35d, supply_change_pct_35d),total_supply AS (SELECT SUM(current_supply) AS total FROM base_data),supply_rank AS (SELECT'supply' AS rank_type,RANK() OVER (ORDER BY current_supply DESC) AS rank,chain,current_supply AS metric_value,ROUND(100.0 * current_supply / (SELECT total FROM total_supply), 2) AS market_share_pctFROM base_data),inflow_rank AS (SELECT'inflow' AS rank_type,RANK() OVER (ORDER BY inflow_35d DESC) AS rank,chain,inflow_35d AS metric_value,CAST(NULL AS DOUBLE) AS market_share_pctFROM base_data),outflow_rank AS (SELECT'outflow' AS rank_type,RANK() OVER (ORDER BY outflow_35d DESC) AS rank,chain,outflow_35d AS metric_value,CAST(NULL AS DOUBLE) AS market_share_pctFROM base_data),net_flow_rank AS (SELECT'net_flow' AS rank_type,RANK() OVER (ORDER BY net_flow_35d DESC) AS rank,chain,net_flow_35d AS metric_value,CAST(NULL AS DOUBLE) AS market_share_pctFROM base_data