Query editor
WITH dense AS (SELECT c.wallet, c.stable_usd,s.is_contract_wallet, s.is_safe_wallet, s.is_account_abstraction_wallet,a.risky_approval_count, b.recent_migration_signal, b.recent_split_funds_signal,(s.wallet_address IS NOT NULL) AS structural_observed,(a.wallet_address IS NOT NULL) AS approvals_observed,(b.wallet_address IS NOT NULL) AS behavioral_observedFROM dune.walletwall.result_dune_query_stablecoin_cohort cLEFT JOIN dune.walletwall.result_dune_query_mig_structural s ON s.wallet_address = c.walletLEFT JOIN dune.walletwall.result_dune_query_mig_approvals a ON a.wallet_address = c.walletLEFT JOIN dune.walletwall.result_dune_query_mig_behavioral b ON b.wallet_address = c.wallet)SELECTcount(*) AS cohort_n,approx_percentile(stable_usd, 0.50) AS stable_usd_p50,approx_percentile(stable_usd, 0.90) AS stable_usd_p90,approx_percentile(stable_usd, 0.99) AS stable_usd_p99,count_if(structural_observed) AS structural_observed_n,count_if(is_contract_wallet) AS is_contract_true_n,count_if(is_safe_wallet) AS is_safe_true_n,count_if(is_account_abstraction_wallet) AS is_aa_true_n,count_if(approvals_observed) AS approvals_observed_n,approx_percentile(risky_approval_count, 0.99) AS risky_approval_p99,count_if(risky_approval_count > 0) AS risky_approval_positive_n,count_if(behavioral_observed) AS behavioral_observed_n,count_if(recent_migration_signal) AS migration_signal_true_n,count_if(recent_split_funds_signal) AS split_funds_true_n,current_timestamp AS distribution_as_ofFROM dense