title: Finding the Sum based on Group using Flux Query - InfluxDB
body: <p>I am trying to use flux query language to find the sum of a column based on a person.
  If I have the following input table:</p>
  <p><a href="https://i.stack.imgur.com/qj1wP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qj1wP.png" alt="enter image description here" /></a></p>
  <p>How can I use a Flux Query to obtain the following output table:</p>
  <p><a href="https://i.stack.imgur.com/goiuX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/goiuX.png" alt="enter image description here" /></a></p>
  <p>I have tried something like this so far but I get errors:</p>
  <pre><code>from: (bucket: &quot;example&quot;)
    |&gt; range(start:v.timeRangeStart, stop: v.timeRangeStop)
    |&gt; filter(fn: (r)=&gt; r[&quot;_measurement&quot;] == &quot;test&quot;)
    |&gt; group(columns: r[&quot;person&quot;])
    |&gt; reduce( fn: (r, accumulator) =&gt; ({sum: r._value + accumulator.sum}), identity: {sum: 0})
  </code></pre>