Query editor
-- ========================-- Solana (single-scan, double-counting preserved)-- ========================WITH addresses AS (SELECT addressFROM dune.devjosh.dataset_solana_addresses AS t(address)),matched_transfers AS (SELECTt.amount/1e6 AS token_value,t.block_time,a_from.address IS NOT NULL AS is_withdrawal,a_to.address IS NOT NULL AS is_depositFROM tokens_solana.transfers tLEFT JOIN addresses a_from ON t.from_owner = a_from.addressLEFT JOIN addresses a_to ON t.to_owner = a_to.addressWHERE t.block_date >= DATE '2024-12-20'AND t.token_mint_address IN ('Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB','EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v')AND (a_from.address IS NOT NULL OR a_to.address IS NOT NULL)),all_transfers AS (SELECT token_value, block_time, 'withdrawal' AS transaction_typeFROM matched_transfers WHERE is_withdrawalUNION ALLSELECT token_value, block_time, 'deposit' AS transaction_typeFROM matched_transfers WHERE is_deposit),grouped AS (SELECTDATE_TRUNC('month', block_time) AS month,transaction_type,SUM(ABS(token_value)) AS volFROM all_transfersGROUP BY 1, 2),monthly AS (SELECT month, SUM(vol) AS "USD_Volume", NULL AS "Type", NULL AS "Volume", NULL AS "Category"FROM grouped GROUP BY month),breakdown AS (SELECT NULL AS month, NULL AS "USD_Volume", transaction_type AS "Type", SUM(vol) AS "Volume", 'breakdown' AS "Category"FROM grouped GROUP BY transaction_type),total AS (SELECT NULL AS month, NULL AS "USD_Volume", 'Total Volume' AS "Type", SUM(vol) AS "Volume", 'summary' AS "Category"FROM grouped)SELECT month, "USD_Volume", "Type", "Volume", "Category" FROM monthlyUNION ALLSELECT month, "USD_Volume", "Type", "Volume", "Category" FROM breakdownUNION ALLSELECT month, "USD_Volume", "Type", "Volume", "Category" FROM totalORDER BYCASE WHEN "Category" IS NULL THEN 0 WHEN "Category" = 'breakdown' THEN 1 ELSE 2 END,month DESC NULLS LAST, "Type"