title: Doctrine query builder - group by on alias
body: <p>I have this query done with query builder:</p>
  
  <pre><code>$qb = $this-&gt;createQueryBuilder ( 'x' );
  $qb-&gt;innerJoin ( 'x.unitelement', 'ue', 'WITH', 'ue.id=x.unitelement' );
  $qb-&gt;innerJoin ( 'ue.object', 'o', 'WITH', 'o.id=ue.object' );
  $qb-&gt;select ( 'o.id, o.name, AVG(x.evaluation) AS vi, YEAR(x.date) as yyyy' );
  $qb-&gt;where('x.evaluation IS NOT NULL');
  $qb-&gt;andWhere('x.evaluation &gt;= 0');
  $qb-&gt;andWhere('x.date IS NOT NULL');
  $qb-&gt;groupBy ( 'o.id, o.name, x.date' );
  $qb-&gt;orderBy('yyyy');
  $query = $qb-&gt;getQuery ();
  </code></pre>
  
  <p>I need to group results by 'yyyy' alias, but if I insert yyyy alias into groupBy, i got error.</p>
  
  <p>Someone have solution to transform this sql in Doctrine Query Builder:</p>
  
  <pre><code>SELECT o.name, AVG(x.Evaluation) AS vi, YEAR(x.[Date]) AS yr
  FROM [Inspection] AS x
  INNER JOIN [UnitElement] AS ue
  ON ue.id=x.UnitElement_ID
  INNER JOIN Object AS o
  ON o.id=ue.[Object_ID]
  WHERE x.evaluation IS NOT NULL
  AND x.evaluation &gt;= 0
  AND x.[Date] IS NOT NULL
  GROUP BY o.id, o.name, YEAR(x.[Date])
  ORDER BY vi DESC;
  </code></pre>
  
  <p>Thanks</p>