title: How can I SELECT rows with MAX(Column value) in DQL?
body: <p>I can not get this query in a symfony2 project that I have.</p>
  
  <p><strong>My Table:</strong></p>
  
  <pre><code>id  course  datetime    numOrden   
  ---|-----|------------|--------
  1  | 1º  | 04/11/2016 | 1   
  2  | 2º  | 04/11/2016 | 2
  5  | 3º  | 04/11/2016 | 5  
  3  | 4º  | 03/11/2016 | 4   
  4  | 5º  | 03/11/2016 | 3 
  </code></pre>
  
  <p>I need to get the course whose value in the "numOrden" column is the maximum( in this case it would be the 3rd course). For this I have used the following query in Doctrine2:</p>
  
  <pre><code>public function findCourse()
  {
      return $this-&gt;getEntityManager()-&gt;createQuery(
      'SELECT c FROM BackendBundle:Curso c WHERE c.numOrden in (SELECT max(c.numOrden) FROM BackendBundle:Curso )')
      -&gt;getResult();
  }
  </code></pre>
  
  <p>Or</p>
  
  <pre><code>    public function findCourse()
  {
      return $this-&gt;getEntityManager()-&gt;createQuery(
      'SELECT c FROM Bundle:Course c WHERE c.numOrden=(SELECT max(c.numOrden) FROM Bundle:Course )')
      -&gt;getResult();
  }
  </code></pre>
  
  <p>But it shows the following error:</p>
  
  <pre><code>[Syntax Error] line 0, col -1: Error: Expected Doctrine\ORM\Query\Lexer::T_CLOSE_PARENTHESIS, got end of string. (500 Internal Server Error)  
  </code></pre>