title: Mongo subtract in group aggregation
body: <p>I have a mongo query and I need to group and than subtract min value from max value and I have issues doing that. </p>
  
  <p>Here is my query:</p>
  
  <pre><code>{
      $group : {
          _id :  {
              type: "$type",
              id : "$id"
              },
          sent : {$subtract: [{$max : "$value"}, {$min : "$value"}]}
      }
  }
  </code></pre>
  
  <p>But I get this error message:</p>
  
  <blockquote>
    <p>The $subtract accumulator is a unary operator</p>
  </blockquote>
  
  <p>I would like to know how do I subtract inside the group stage.</p>