Query editor
/* Migration success :)There are some cases such as unnest/sequence and array/json functions the migrator won't take care of for you(but we have examples of in the docs linked below!)If you're still running into issues, check out the doc examples https://dune.com/docs/reference/dune-v2/query-engine/or reach out to us in the Dune discord in the #dune-sql channel.*//* !Bytea parameter warning: Make sure to change \x to 0x in the parameters, bytea types are native now (no need for quotes or lower or \x)' */WITHwrapper AS (WITHswap_aggs AS (WITHpersonal_volume AS (SELECTSUM(CAST(amount_usd AS DOUBLE)) FILTER (WHEREtx_from = {{Wallet Address}}) AS volumeFROMdex.tradesWHERE(blockchain = 'ethereum'AND tx_to = 0x881d40237659c251811cec9c364ef91dc08d300c)OR(blockchain = 'polygon'and tx_to = 0x1a1ec25DC08e98e5E93F1104B5e5cdD298707d31)),other_volume AS (SELECTtx_from AS wallet,SUM(CAST(amount_usd AS DOUBLE)) AS volumeFROMdex.tradesWHERE(blockchain = 'ethereum'AND tx_to = 0x881d40237659c251811cec9c364ef91dc08d300c)OR(blockchain = 'polygon'and tx_to = 0x1a1ec25DC08e98e5E93F1104B5e5cdD298707d31)GROUP BYtx_from)SELECTCOUNT(DISTINCT other_volume.wallet) FILTER (WHEREother_volume.volume > personal_volume.volume + 1000) AS more_volume,COUNT(DISTINCT other_volume.wallet) FILTER (WHEREother_volume.volume < personal_volume.volume - 1000) AS less_volume,COUNT(DISTINCT other_volume.wallet) FILTER (WHEREABS(other_volume.volume - personal_volume.volume) <= 1000) AS same_volumeFROMother_volumeLEFT JOIN personal_volume ON 1 = 1