title: Find overall min and max values in aggregate group results with single query
body: <p>I've an object stored into my collection that looks like this:</p>
  
  <pre><code>[{ 
      "_id" : ObjectId("56bcbe570793be2e5025567e"),   
      "CarPlate" : "AB123CD", 
      "Brand" : "BMW", 
      "Version" : "316d", 
      "Description" : "BMW 316d", 
      "Prices" : [
          {
              "PriceType" : NumberInt(0), 
              "VatType" : NumberInt(0), 
              "Currency" : "EUR", 
              "Value" : 20100.0
          }, 
          {
              "PriceType" : NumberInt(3), 
              "VatType" : NumberInt(0), 
              "Currency" : "EUR", 
              "Value" : 23900.0
          }, 
          {
              "PriceType" : NumberInt(4), 
              "VatType" : null, 
              "Currency" : "EUR", 
              "Value" : 30950.0
          }
      ]
  }, { 
      "_id" : ObjectId("56bcbe570793be2e5025567f”),   
      "CarPlate" : "AB123CE”, 
      "Brand" : "BMW", 
      "Version" : "318d", 
      "Description" : "BMW 318d", 
      "Prices" : [
          {
              "PriceType" : NumberInt(0), 
              "VatType" : NumberInt(0), 
              "Currency" : "EUR", 
              "Value" : 23900.0
          }, 
          {
              "PriceType" : NumberInt(3), 
              "VatType" : NumberInt(0), 
              "Currency" : "EUR", 
              "Value" : 23900.0
          }, 
          {
              "PriceType" : NumberInt(4), 
              "VatType" : null, 
              "Currency" : "EUR", 
              "Value" : 40250.0
          }
      ]
  }]
  </code></pre>
  
  <p>I'd like to retrieve the min and max price values [for the entire collection] where PriceType is equal to 4 using a single query.</p>
  
  <p>I found a way to do that but running two different queries (basically the same query but with a different sort)</p>
  
  <pre><code>db.Cars.aggregate(
    [
      {
        $unwind: '$Prices'
      },
      {
        $match: {
        'Prices.PriceType': 4
        }
      },
      {
        $group: {
          _id: '$CarPlate',
          valueMin: { $min: '$Prices.Value' },
          valueMax: { $max: '$Prices.Value' }
        }
      },
      {
        $sort: {
          valueMin: 1
        }
      },
      {
        $limit: 1
      }
    ]
  );
  </code></pre>
  
  <p>Any hint?</p>