title: How to group rows by sums in BigQuery?
body: <p>I want to partition BigQuery table by sums of values equal some number
  For example:
  Values: <code>10, 11, 20, 53, 14, 15, 5</code>. It must be partitioned by sum of values equal 30 or first cumulative sum after 30. Like card game &quot;black jack&quot;. When sum values it's not enough for 30 needs to take next value.
  Expected output:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>name     value   total
     first part 
  d        53      53
     second part
  c        20      35
  f        15
     third part
  e        14      35
  b        11
  c        10</code></pre>
  </div>
  </div>
  </p>
  <p><code>5</code> - must stay out of selection cuz it is sum less then 30.</p>
  <p>My query can count cumulative sums only. But how can I modify this to get expected output?</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>SELECT name, value, SUM(value) OVER (ORDER BY value) AS RunningTotal, 
  FROM 
  (SELECT "a" AS name, 10 AS value
  UNION ALL
  SELECT "b" AS name, 11 AS value
  UNION ALL
  SELECT "c" AS name, 20 AS value
  UNION ALL
  SELECT "d" AS name, 53 AS value
  UNION ALL
  SELECT "e" AS name, 14 AS value
  UNION ALL
  SELECT "f" AS name, 15 AS value
  UNION ALL
  SELECT "g" AS name, 5 AS value)</code></pre>
  </div>
  </div>
  </p>