title: Mysql 8.0 - Calculating Moving Average
body: <p>Currently, I'm working on a database on Amazons rds platform, and i'm connecting through mysql server.</p>
  
  <p>At some point, I need to perform a rolling average of the form:</p>
  
  <pre><code>SELECT
  id, x_axis,time,
  AVG(x_axis) OVER (ORDER BY time
  ROWS BETWEEN 8 PRECEDING AND 0 FOLLOWING)
  AS running_average
  FROM falla_machinedata
  ORDER BY id;
  </code></pre>
  
  <p>The error I get is the following:</p>
  
  <pre><code>ERROR 1064 (42000): You have an error in your SQL syntax; check the
  manual that corresponds to your MySQL server version for the right
  syntax to use near '(ORDER BY time ROWS BETWEEN 8 PRECEDING AND 0
  FOLLOWING)AS running_aver' at line 3
  </code></pre>
  
  <p>I've tried with different tutorials to perform this operation, and the result is always the same. I always get a syntax error. </p>
  
  <p>Can you help me figure out what if the problem here?. Thanks in advance.</p>