title: BigQuery SQL running totals
body: <p>Any idea how to calculate running total in BigQuery SQL?  </p>
  
  <pre><code>id   value   running total
  --   -----   -------------
  1    1       1
  2    2       3
  3    4       7
  4    7       14
  5    9       23
  6    12      35
  7    13      48
  8    16      64
  9    22      86
  10   42      128
  11   57      185
  12   58      243
  13   59      302
  14   60      362 
  </code></pre>
  
  <p>Not a problem for traditional SQL servers using either correlated scalar query: </p>
  
  <pre><code>SELECT a.id, a.value, (SELECT SUM(b.value)
                         FROM RunTotalTestData b
                         WHERE b.id &lt;= a.id)
  FROM   RunTotalTestData a
  ORDER BY a.id;
  </code></pre>
  
  <p>or join:</p>
  
  <pre><code>SELECT a.id, a.value, SUM(b.Value)
  FROM   RunTotalTestData a,
         RunTotalTestData b
  WHERE b.id &lt;= a.id
  GROUP BY a.id, a.value
  ORDER BY a.id;
  </code></pre>
  
  <p>But I couldn't find a way to make it work in BigQuery...</p>