title: Aggregate $sum values from two arrays
body: <p>I have this collection</p>
  
  <pre><code>{
      "_id" : ObjectId("54f46f18c36dcc206d0cec38"),
      "project" : 23123,
      "title" : "Change of windows",
      "description": "Change to better windows on building A"
      "costs":[
        {
          category: 'Produktionskostnad',
          value: 3000
        },
        {
          category: 'Projekteringskostnad',
          value: 2000
        },
        {
          category: 'Overhead',
          value: 1000
        }
      ],
      "energySaving" : [ 
          {
              "energy" : "electricity",
              "type" : "lighting",
              "value" : 24324
          }, 
          {
              "energy" : "electricity",
              "type" : "equipment",
              "value" : 24324
          }, 
          {
              "energy" : "electricity",
              "type" : "fans",
              "value" : 24324
          }, 
          {
              "energy" : "electricity",
              "type" : "distribution",
              "value" : 24324
          }, 
          {
              "energy" : "electricity",
              "type" : "chiller",
              "value" : 24324
          }, 
          {
              "energy" : "electricity",
              "type" : "other",
              "value" : 24324
          }
      ]
  }
  </code></pre>
  
  <p>I need a aggregation that calculates the total cost and the total energySaving.</p>
  
  <p>To get the saving I have this query:</p>
  
  <pre><code>db.collection.aggregate( [
      { $unwind: "$energySaving" },
      { 
         $group: {
            _id: {
               title: '$title',
               description: '$description' 
            },
            totalEnergySaving: { $sum: '$energySaving.value' } 
         } 
      }
  ]);
  </code></pre>
  
  <p>But how do I calculate the total cost in the same query? I cant add $unwind cost in the same query. Can I "reset" the $group somehow and to the query again?</p>