Query editor
WITH total AS (SELECT*,ROW_NUMBER() OVER (PARTITION BY tx_from ORDER BY block_date) AS ord_rnkFROM (SELECTtx_hash,tx_from,tx_to,block_date,evt_index,amount_usd,MAX(evt_index) OVER (PARTITION BY tx_hash) AS indexFROM dex.tradesWHEREtx_to IN (SELECTaddressFROM dune.lz_web3.dataset_crypto_wallet_router)AND NOT amount_usd IS NULLAND DATE(block_date) >= DATE(CAST('2023-01-01' AS TIMESTAMP)))WHEREevt_index = index)SELECTDATE_TRUNC('month', t.block_date) AS dt,r.name,COUNT(DISTINCT t.tx_from) AS mau,COUNT(DISTINCT t.tx_hash) AS transactions,SUM(t.amount_usd) AS amount_usd,COUNT(DISTINCT CASE WHEN t.ord_rnk = 1 then t.tx_from end) AS new_usersFROM total AS tLEFT JOIN (SELECT DISTINCTaddress,nameFROM dune.lz_web3.dataset_crypto_wallet_router) AS rON r.address = t.tx_toGROUP BY1,r.nameORDER BYdt DESC,2