I'm using Doctrine and DQL function createQuery()
and I have this query :
SELECT id, 1 + (
SELECT count( * )
FROM user a
WHERE a.points > b.points ) AS RNK, points
FROM user b
This query return a rank calculated with the field points
.
How can I convert this query for use in createQuery() ?
For now I have :
$query = $this->getEntityManager()->createQuery("
SELECT id, 1+(
SELECT count(*)
from AppBundle\Entity\User a
WHERE a.points > b.points) as RNK, points
FROM AppBundle\Entity\User b
");
But this return a syntax error : "[Syntax Error] line 0, col 14: Error: Expected Literal, got 'SELECT'"