title: Inner join in symfony query builder
body: <p>I have problem to write this sql query in QueryBuilder:</p>
  
  <pre><code>SELECT SUM(TableA.SUM) AS TOTAL, TableB.name 
      FROM TableA INNER JOIN TableB ON TableA.category_id = TableB.id GROUP BY TableB.name
  </code></pre>
  
  <p>it's work when i called it into mysql query. And i get something like:</p>
  
  <p>Category   | TOTAL
  category a | 40
  category b | 67
  category c | 5</p>
  
  <p>My Expenditure Entity class: </p>
  
  <pre><code>/**
   * Expenditure
   *
   * @ORM\Table(name="accountant_expenditure")
   * @ORM\Entity(repositoryClass="accountant\ExpenditureBundle\Repository\ExpenditureRepository")
   */
  class Expenditure
  {
      /**
       * @var integer
       *
       * @ORM\Column(name="id", type="integer")
       * @ORM\Id
       * @ORM\GeneratedValue(strategy="AUTO")
       */
      private $id;
  
      /**
       * @ORM\ManyToOne(targetEntity="accountant\UserBundle\Entity\User")
       * @ORM\JoinColumn(name="create_by_user_id", referencedColumnName="id", onDelete="CASCADE")
       */
      private $createBy;
  
      /**
       * @var \DateTime
       *
       * @ORM\Column(name="create_at", type="datetime")
       */
      private $createAt;
  
      /**
       * @var integer
       *
       * @ORM\ManyToOne(targetEntity="accountant\ExpenditureBundle\Entity\ExpenditureCategories")
       * @ORM\JoinColumn(name="category_id", referencedColumnName="id", onDelete="CASCADE")
       */
      private $category;
  
      /**
       * @var float
       *
       * @ORM\Column(name="sum", type="float")
       */
      private $sum;
  //...
  </code></pre>
  
  <p>ExpenditureCategories entity class:</p>
  
  <pre><code>/**
   * ExpenditureCategories
   *
   * @ORM\Table()
   * @ORM\Entity(repositoryClass="accountant\ExpenditureBundle\Repository\ExpenditureCategoriesRepository")
   */
  class ExpenditureCategories
  {
      /**
       * @var integer
       *
       * @ORM\Column(name="id", type="integer")
       * @ORM\Id
       * @ORM\GeneratedValue(strategy="AUTO")
       */
      private $id;
  
      /**
       * @var string
       *
       * @ORM\Column(name="name", type="string", length=255)
       */
      private $name;
  //...
  </code></pre>
  
  <p>I write something like this but it's not correct:</p>
  
  <pre><code>public function findCurrentMonthExpendituresSumByCategory()
      {
          $firstDay = new \DateTime('first day of this month');
          $lastDay = new \DateTime('last day of this month');
  
          return $this-&gt;createQueryBuilder('e')
              -&gt;select('SUM(e.sum) AS TOTAL, c.name')
              -&gt;from('ExpenditureBundle:ExpenditureCategories', 'c')
              -&gt;leftJoin('e.category', 'c')
              -&gt;where('e.createAt BETWEEN :start AND :end')
              -&gt;setParameter('start', $firstDay-&gt;format('Y-m-d'))
              -&gt;setParameter('end', $lastDay-&gt;format('Y-m-d'))
              -&gt;groupBy('c.name')
              -&gt;getQuery()
              -&gt;getResult();
      }
  </code></pre>
  
  <p>Maybe it's problem with my annotations in entities? 
  I get:</p>
  
  <pre><code>[Semantical Error] line 0, col 154 near 'c WHERE e.createAt': Error: 'c' is already defined.
  </code></pre>
  
  <p>Really thanks for help anyway ;) </p>