title: Doctrine: GROUP BY HAVING
body: <p>I'm trying to do this:</p>
  
  <pre><code>SELECT 
       userId, count(userId) as counter 
   FROM 
       quicklink 
   GROUP BY 
       userId 
   HAVING 
       count(*) &gt;= 3'
  </code></pre>
  
  <p>In doctrine with the querybuilder, I've got this:</p>
  
  <pre><code>$query = $this-&gt;createQueryBuilder('q')
              -&gt;select('userId, count(userId) as counter')
              -&gt;groupby('userId')
              -&gt;having('counter &gt;= 3')
              -&gt;getQuery();
  
          return $query-&gt;getResult();
  </code></pre>
  
  <p>Which gives me this error: </p>
  
  <pre><code>[Semantical Error] line 0, col 103 near 'HAVING count(*)': Error: Cannot group by undefined identification variable.
  </code></pre>
  
  <p>Really struggling with doctrine. :(</p>