title: QueryBuilder/Doctrine Select join groupby
body: <p>So recently I have been thinking and can't find a solution yet to this problem since my lack of development with doctrine2 and symfony query builder.</p>
  
  <p>I have 2 tables:
  Goals: id,user_id,target_value...
  Savings: id,goal_id,amount</p>
  
  <p>And I need to make a select from goals (all the informations in my table are from the goals table, except that I need to make a SUM(amount) from the savings table on each goal, so I can show the user how much did he saved for his goal)</p>
  
  <p>This is the MySQL query:</p>
  
  <pre><code>    select 
  
      admin_goals.created,
      admin_goals.description,
      admin_goals.goal_date,
      admin_goals.value,
      admin_goals.budget_categ,
      sum(admin_savings.value) 
  
      from admin_goals 
  inner join admin_savings on admin_savings.goal_id=admin_goals.id 
      where admin_goals.user_id=1 
      group by admin_goals.id
  </code></pre>
  
  <p>It returns what I want but I have no idea how to implement it with doctrine or query builder, can you please show me an example in both ways?
  <img src="https://i.stack.imgur.com/6emet.png" alt="enter image description here">
  I highly appreciate it !
  <img src="https://i.stack.imgur.com/Ttn9g.png" alt="enter image description here"></p>