title: Sum all amount per user in Doctrine Group By Symfony2
body: <p>I want to get sum of each amount related to a user</p>
  
  <p>this is my original code</p>
  
  <pre><code>public function getUserForThisTask($projectId)
  {
    $qb = $this-&gt;createQueryBuilder('t')
        -&gt;select('t.createdby','t.totalhour')
        -&gt;where('t.project = :project_id')
        -&gt;setParameter('project_id', $projectId);
        return $qb-&gt;getQuery()
                  -&gt;getResult();
  }
  </code></pre>
  
  <p>This will return </p>
  
  <pre><code>  user     hours
    user1  = 20
    user2  = 30
    user1  = 3
    user1  = 4
  </code></pre>
  
  <p>Now I refactor by adding groupBy </p>
  
  <pre><code>  public function getUserForThisTask($projectId)
  {
    $qb = $this-&gt;createQueryBuilder('t')
        -&gt;select('t.createdby','t.totalhour')
        -&gt;groupBy('t.createdby')
        -&gt;where('t.project = :project_id')
        -&gt;setParameter('project_id', $projectId);
        return $qb-&gt;getQuery()
                  -&gt;getResult();
  }
  </code></pre>
  
  <p>Now this will be the result, as you see, some values related to user1 is not included</p>
  
  <pre><code>user    hours
  user1  =  20
  user2 =  30
  </code></pre>
  
  <p>Now I want this to total all hours related to each users </p>
  
  <pre><code>user    hours
  user1 = 27
  user2 = 30
  </code></pre>
  
  <p>How would you do thi?</p>