title: Is there a way to do rolling averages in Big Query?
body: <p>I know there is an AVG function in Big Query and there are window functions to shift previous or next values up or down a row, but is there any function that allows you to average over a specified interval?  For instance I'd like to so something like the following:</p>
  
  <pre><code>SELECT
      city
      AVG(temperature) OVER(PARTITION BY city, INTERVAL day,14, ORDER BY day) as rolling_avg_14_days,
      AVG(temperature) OVER(PARTITION BY city, INTERVAL day,30, ORDER BY day) as rolling_avg_30_days,
  WHERE
      city IN ("Los Angeles","Chicago","Sun Prairie","Sunnyvale")
      AND year BETWEEN 1900 AND 2013
  </code></pre>
  
  <p>I'd like to do a rolling average calculation that allows me to specify a range of values to do an aggregation function over, and what value to order by.  The average function would take the current day temp and previous 13 days (or previous 29) to calculate and average.  Is this possible today?  I know I could do something like this if I put 13 LAG/OVER fields in the SELECT statement and then avg the results of all of them, but that is a lot of overhead.  </p>