Query editor
-- This query used incompatible data types from Dune SQL alpha and may need to be updated.-- More details can be found on https://dune.com/docs/query/dunesql-changes/withtxs as (SELECTtx_id,amount / 1e6 as fee_usd,from_owner as traderFROM tokens_solana.transfersWHEREto_owner = 'R4rNJHaffSUotNmqSKNEfDcJE8A7zJUkaoM5Jkd7cYX'and token_mint_address = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'and block_time >= TIMESTAMP '2025-04-01'),deduped_trades AS (SELECTa.tx_id,a.block_time,a.amount_usd,a.token_bought_symbol,a.token_sold_symbol,ROW_NUMBER() OVER (PARTITION BY a.tx_id ORDER BY a.amount_usd DESC) AS trade_rank,b.*FROM dex_solana.trades ainner join txs bon a.tx_id = b.tx_id),trades_filtered AS (SELECT * FROM deduped_trades WHERE trade_rank = 1),base as (SELECTdistinctdate_trunc('month', block_time) as month, trader as userFROM trades_filtered), user_cohort as (--get the cohort start month for a specific user addressSELECTmin(month) as cohort, userFROM basegroup by 2), cohort_size as (SELECTcohort, count(*) as total_sizeFROM user_cohortgroup by 1), active_by_cohort as (SELECT