title: How to make a sum only query in a whole collection?
body: <p>I have this collection</p>
  <pre><code>{ 
      &quot;_id&quot; : BinData(0, &quot;JUw6VoBVdtqAQ2g7sn0sog==&quot;), 
      &quot;os_name&quot; : &quot;android&quot; 
  }
  </code></pre>
  <p>I want to retrieve in one aggregate query to count of documents with</p>
  <pre><code>os_android =&gt; count of documents where &quot;os_name&quot; = &quot;android&quot; 
  os_ios =&gt; count of documents where &quot;os_name&quot; = &quot;ios&quot;
  total =&gt; the total count of document
  </code></pre>
  <p>How can i do ?</p>
  <p>I try this :</p>
  <pre><code>db.getCollection(&quot;myCollection&quot;).aggregate(
  [
      {$group:{
        _id:{},
        by_os_ios:{$sum:{$cond:[{os_name:&quot;ios&quot;},NumberInt(1),NumberInt(0)]}},
        by_os_android:{$sum:{$cond:[{os_name:&quot;android&quot;},NumberInt(1),NumberInt(0)]}},
        total:{$sum:1}}
      },
      {$addFields:{
        &quot;by_os.ios&quot;:&quot;$by_os_ios&quot;,
        &quot;by_os.android&quot;:&quot;$by_os_android&quot;}},
      {$project:{
        _id:0,
        by_os_ios:0,
        by_os_android:0}}
    ]
  );
  </code></pre>
  <p>but it's not work :( what did I miss ?</p>