title: Aggregate SUM with Doctrine2 and QueryBuilder
body: <p>in my repository class I have this, but the query is not working.</p>
  
  <pre><code> public function getResultsByName($page, $resultsCount, array $request_arr){     
   $qb = $this-&gt;createQueryBuilder('xx'); 
   $qb-&gt;addSelect('SUM(xx.quantity) as total')
      -&gt;leftJoin('xx.reception', 'x')
      -&gt;addSelect('x')
      -&gt;leftJoin('x.purchase', 'p')
      -&gt;addSelect('p')
      -&gt;leftJoin('p.provider', 'pr')
      -&gt;addSelect('pr')
      -&gt;where('pr.id = :company_id')
      -&gt;setParameter('company_id', $request_arr['company_id']);
  
   $query = $qb-&gt;getQuery(); 
  
   return parent::getPaginator($query, $page, $resultsCount); }
  </code></pre>
  
  <p>The error is appearing in my twig template this is the important chunk of it </p>
  
  <pre><code>    {% for result in results %}
  &lt;tr&gt;
      &lt;td&gt;{{result.reception.id}}&lt;/td&gt;
      &lt;td&gt;{{result.reception.date|date('d-m-Y')}}&lt;/td&gt;
      &lt;td&gt;{{result.reception.purchase.id}}&lt;/td&gt;
      &lt;td&gt;{{result.reception.purchase.provider.name|upper}} [{{result.reception.purchase.provider.id}}]&lt;/td&gt;
      &lt;td&gt;{{result.purchaseProduct.name |upper}} [{{result.purchaseProduct.productCode |upper}}]&lt;/td&gt;
      &lt;td&gt;{{result.purchasePrice}}&lt;/td&gt;
      &lt;td&gt;{{result.quantity}}&lt;/td&gt;
      &lt;td&gt;&lt;/td&gt;
      &lt;td&gt;{{result.quantityStock}}&lt;/td&gt;
  &lt;/tr&gt;   
  {% endfor %}
  </code></pre>