Query editor
WITH relevant_transfers AS (SELECTblock_date,from_owner,to_owner,token_mint_address,-- amount_display, -- Not directly used in StrictMonthlyPayments, but good for visibilitytx_idFROMtokens_solana.transfersWHEREtoken_mint_address IN ('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', -- USDC'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB', -- USDT'So11111111111111111111111111111111111111112' -- SOL)AND amount_display >= 1AND action = 'transfer'AND block_date >= DATE '2024-06-01'AND block_date <= DATE '2024-07-31'),-- OPTIMIZED StrictMonthlyPayments using ROW_NUMBER and QUALIFYmonthly_payments AS (SELECTmonth_start,from_owner,to_owner,token_mint_addressFROM (SELECTDATE_TRUNC('month', block_date) AS month_start,from_owner,to_owner,token_mint_address,COUNT(DISTINCT tx_id) AS distinct_tx_count_in_monthFROMrelevant_transfersGROUP BYDATE_TRUNC('month', block_date),from_owner,to_owner,token_mint_address) AS monthly_tx_countsWHEREdistinct_tx_count_in_month = 1 -- Filter for exactly one distinct transfer)SELECT * FROM monthly_payments