I'm having a problem with counting some aggregations.
Part of code looks like this:
$qb->select($qb->expr()->countDistinct('policy.calculation', 'policy.id'))
->getQuery()
->getSingleScalarResult();
In sql it's possible to count distinct on multiple columns, and from DQL I'm getting an error:
[Syntax Error] line 0, col 40: Error: Expected Doctrine\ORM\Query\Lexer::T_CLOSE_PARENTHESIS, got ','
Can I get this working?
From expression builder:
/**
* Creates an instance of COUNT(DISTINCT) function, with the given argument.
*
* @param mixed $x Argument to be used in COUNT(DISTINCT) function.
*
* @return string
*/
public function countDistinct($x)
{
return 'COUNT(DISTINCT ' . implode(', ', func_get_args()) . ')';
}
It's looks like this should work.