title: How to get summarized report in MongoDB
body: <p>I have documents in the following structure.</p>
  
  <p><strong>Sample Document :</strong></p>
  
  <pre><code>   {
          "location" : {
              "street" : {
                  "number" : 9360,
                  "name" : "Travessa dos Açorianos"
              },
              "coordinates" : {
                  "latitude" : -69.3199,
                  "longitude" : 154.0748
              },
              "timezone" : {
                  "offset" : "-8:00",
                  "description" : "Pacific Time (US &amp; Canada)"
              },
              "city" : "Divinópolis",
              "state" : "Espírito Santo",
              "country" : "Brazil",
              "postcode" : "23089"
          },
          "gender" : "male",
          "login" : {
              "uuid" : "b932ef44-2afb-4b72-a1c5-47b2263bbab2",
              "username" : "goldenfish516",
              "password" : "sharks",
              "salt" : "O7UQElyh",
              "md5" : "9f217bf6d5d8576703dbd38e864f709f",
              "sha1" : "22a4dbba7eea9b47537ed9931b907ceae10f4de7",
              "sha256" : "2bcf93087fcd2ecc623702ad5727e5a24f33ee343c1871028a7950e770c53ee4"
          },
          "dob" : {
              "date" : ISODate("1983-09-10T18:56:41.614Z"),
              "age" : 37   // get report from  based on age of male and female using nat field
          },
          "registered" : {
              "date" : ISODate("2005-04-10T08:57:39.425Z"),
              "age" : 15
          },
  
          "nat" : "NL",
       }
  </code></pre>
  
  <p>I want to generate Summarized report, How can I get both records <strong>male</strong> and <strong>female</strong> based on age &amp; nationality using mongo.</p>
  
  <p><strong>Required output :</strong></p>
  
  <p><a href="https://i.stack.imgur.com/yYlBT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yYlBT.png" alt="enter image description here"></a></p>