title: How to find date wise sum and total sum of all date at a time in mongodb?
body: <p>I have a collection billow and i need to find date wise total cost and sum of all cost available in this collection. I can find total cost of a day but failed to get sum of all cost from the collection</p>
  <pre><code>[{
          &quot;date&quot;:&quot;12-2-2015&quot;,
          &quot;cost&quot;:100
      },
      {
          &quot;date&quot;:&quot;13-2-2015&quot;,
          &quot;cost&quot;:10
      },
      {
          &quot;date&quot;:&quot;12-2-2015&quot;,
          &quot;cost&quot;:40
      },
      {
          &quot;date&quot;:&quot;13-2-2015&quot;,
          &quot;cost&quot;:30
      },
      {
          &quot;date&quot;:&quot;13-2-2015&quot;,
          &quot;cost&quot;:80
      }]
  </code></pre>
  <p>I can find output like</p>
  <pre><code>    [{
          &quot;day&quot;: &quot;12-2-2015&quot;,
          &quot;cost&quot;: 140
      },{
          &quot;day&quot;: &quot;13-2-2015&quot;,
          &quot;cost&quot;: 120
      }]
  </code></pre>
  <p>But I want output like this.</p>
  <pre><code>{
     &quot;day&quot;: &quot;12-2-2015&quot;,
     &quot;cost&quot;: 140,
     &quot;total&quot;: 260
   }
  </code></pre>