您正在开展一个项目,我希望对数据进行分组,即对存在ID的记录进行分组,如果id为null,则不要应用分组 例如我有1,2,3,NULL,NULL,1它应该给出输出1,2,3,NULL,NULL。我的查询在数据库中给出了正确的输出,但是当我在doctrine中使用该查询时出错。提前提醒
$em = $this->getEntityManager();
$queryBuilder123 = $em->createQueryBuilder();
$queryBuilder123->select("obj.batchFormationId as batchId")
->add('from', 'Owner\Entity\Batchformation obj')
->leftjoin('\Owner\Entity\Batchtrainer', 'br', Join::WITH, 'br.batchFormationId=obj.batchFormationId')
->groupBy("br.batchFormationId, CASE WHEN br.batchFormationId IS NULL THEN obj.batchFormationId ELSE 0 END");
$result123 = $queryBuilder123->getQuery()->getArrayResult();