title: How to order by count in Doctrine 2?
body: <p>I'm trying to group my entity by a field (year) and do a count of it.</p>
  
  <p>Code:</p>
  
  <pre class="lang-php prettyprint-override"><code>public function countYear()
  {
      $qb = $this-&gt;getEntityManager()-&gt;createQueryBuilder();
      $qb-&gt;select('b.year, COUNT(b.id)')
          -&gt;from('\My\Entity\Album', 'b')
          -&gt;where('b.year IS NOT NULL')
          -&gt;addOrderBy('sclr1', 'DESC')
          -&gt;addGroupBy('b.year');
      $query = $qb-&gt;getQuery();
      die($query-&gt;getSQL());
      $result = $query-&gt;execute();
      //die(print_r($result));
      return $result;
  }
  </code></pre>
  
  <p>I can't seem to say <code>COUNT(b.id) AS count</code> as it gives an error, and
  I do not know what to use as the <code>addOrderby(???, 'DESC')</code> value?</p>