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.*/WITHavg_daily AS (SELECTDATE_TRUNC('day', minute) AS dt,symbol,AVG(price) AS priceFROMprices.usdWHEREsymbol = '{{symbol}}'GROUP BY1,2ORDER BY1 DESC)SELECTdt,symbol,price,AVG(price) OVER (ORDER BYdt rows BETWEEN 30 precedingAND current row) AS average30,AVG(price) OVER (ORDER BYdt rows BETWEEN 60 precedingAND current row) AS average60,AVG(price) OVER (ORDER BYdt rows BETWEEN 90 precedingAND current row) AS average90,AVG(price) OVER (ORDER BYdt rows BETWEEN 120 precedingAND current row) AS average120,AVG(price) OVER (ORDER BYdt rows BETWEEN {{window_size}} precedingAND current row) AS average_nFROMavg_dailyORDER BY1 DESC