Query editor
-- Retention summary per external wallet: repeat days, repeat weeks, positions per walletWITH w AS (SELECT wallet_addr,COUNT(*) AS positions,COUNT(DISTINCT CAST(opened_at AS date)) AS active_days,COUNT(DISTINCT date_trunc('week', opened_at)) AS active_weeksFROM query_8766977WHERE NOT is_teamGROUP BY 1),agg AS (SELECTCAST(COUNT(*) AS DOUBLE) AS wallets,ROUND(100.0 * COUNT_IF(active_days >= 2) / COUNT(*), 0) AS pct_2plus_days,ROUND(100.0 * COUNT_IF(active_weeks >= 2) / COUNT(*), 0) AS pct_2plus_weeks,ROUND(100.0 * COUNT_IF(active_weeks >= 3) / COUNT(*), 0) AS pct_3plus_weeks,ROUND(100.0 * COUNT_IF(positions >= 5) / COUNT(*), 0) AS pct_5plus_positions,CAST(approx_percentile(positions, 0.5) AS DOUBLE) AS median_positions,ROUND(AVG(positions), 1) AS avg_positionsFROM w)SELECT metric, valueFROM aggCROSS JOIN UNNEST(ARRAY['External wallets', 'Active on 2+ days (%)', 'Active in 2+ weeks (%)', 'Active in 3+ weeks (%)','5+ positions (%)', 'Median positions per wallet', 'Avg positions per wallet'],ARRAY[wallets, pct_2plus_days, pct_2plus_weeks, pct_3plus_weeks, pct_5plus_positions, median_positions, avg_positions]) WITH ORDINALITY AS t(metric, value, ord)ORDER BY ord