title: Mongo average aggregation query with no group
body: <p>I am trying to get the average of a whole field using the aggregation framework in Mongo. However i can't seem to find any example that uses it without a group parameter. </p>
  
  <p>I have the following document structure:</p>
  
  
  
  <pre class="lang-js prettyprint-override"><code> {
        "_id" : ObjectId("5352703b61d2739b2ea44e4d"),
        "Semana" : "2014-02-23 - 2014-03-01",
        "bolsaDeValores" : "7",
        "bvc" : "8",
        "dollar" : "76",
        "ecopetrol" : "51",
        "dollarPrice" : "18"
   }
  </code></pre>
  
  <p>Basically what i want to do is get the average value of the bvc field, and any other numeric one, for the whole collection in the fastest possible way (without using MapReduce as it is less efficient than the Aggregation Framework).</p>
  
  <p>I have tried to group on a greater than zero basis as well but to no avail:</p>
  
  <pre class="lang-js prettyprint-override"><code>db.EvaluatedSentiments.aggregate([
      { "$group": { 
          "bvc" : {"$gt:0"}
          }, 
          {
              "bvc" : { "$avg" : "$bvc"}
          }
      }
  ])
  </code></pre>
  
  <p>I appreciate any help you could provide.</p>
  
  <p>References: <a href="http://docs.mongodb.org/master/MongoDB-aggregation-guide.pdf" rel="noreferrer">Mongo aggregation manual</a></p>