Query editor
WITH combined_wallets AS (SELECTwallet,blockchain,countable_familiesFROM dune.web3cryptotech.result_main_baseUNION ALLSELECTwallet,blockchain,countable_familiesFROM dune.web3cryptotech.result_main_ethereum),-- Step 2: Filter wallets based on the chain parameter and classify them into cohorts.final_cohort_details AS (SELECTwallet,CASEWHEN countable_families = 0 THEN '0 Families'WHEN countable_families = 1 THEN '1 Family'ELSE '2 Families'END AS countable_families_bucketFROM combined_walletsWHERE-- This logic handles the 'all' case and a comma-separated list of chains.'{{chain}}' = 'all' OR blockchain IN (SELECT TRIM(x) FROM UNNEST(SPLIT('{{chain}}', ',')) AS t(x)))-- Step 3: Final aggregation to count users in each cohort.SELECTcountable_families_bucket AS countable_families,COUNT(wallet) AS number_of_usersFROM final_cohort_detailsGROUP BY 1ORDER BY 1