title: MongoDB sum with aggregate
body: <p>I am not able get sum of <code>ammount</code> column. it returns <code>null</code>.
  trying to group it by date.</p>
  
  <pre><code>Array
  (
  [_id] =&gt; MongoId Object
      (
          [$id] =&gt; 5500a655642c87d663b7acd9
      )
  
  [0] =&gt; 1
  [id] =&gt; 1
  [1] =&gt; 5
  [site_id] =&gt; 5
  [2] =&gt; 7
  [ammount] =&gt; 7
  [3] =&gt; 2
  [status] =&gt; 2
  [4] =&gt; 2012-07-04
  [date] =&gt; 2012-07-04
  )
  </code></pre>
  
  <p>my PHP code is here.</p>
  
  <pre><code>  $outt = $db-&gt;command (
          array( 
              "aggregate" =&gt; "tests",
              "pipeline" =&gt; 
                  array( 
                      array( '$match' =&gt; array('$and' =&gt; array(
                                                      array( 'date' =&gt; $date ),
                                                      array('$or'=&gt;$sites)))),
                      array( 
                              '$group' =&gt; array(
                                '_id' =&gt; '$date',
                               'sum' =&gt; array('$sum' =&gt; '$ammount')
                              )
                          )
                  )
          )
      );
  </code></pre>
  
  <p>if i put <code>$ammount</code> as <code>_id</code> it displays <code>ammount</code> without <code>sum</code>.</p>
  
  <p>(P.S. column name <code>$ammount</code> is correct) </p>