Doctrine2 Limit the rows to sum in a query -
i have query return sum, want limit number of rows query, not working.
this query:
$qb = $this->createquerybuilder('result') ->select('sum(result.generalpoints) generalpoints, sum(result.coefficient) coefficient') ->join('result.inscription', 'inscription', join::with, 'inscription.user = :user') ->join('inscription.race', 'race') ->join('inscription.category', 'category', join::with, 'category.generalranking = true') ->join('race.event', 'event') ->join('event.competitionseason', 'competitionseason', join::with, 'competitionseason = :competitionseason') ->orderby('generalpoints', 'desc') ->addorderby('coefficient', 'desc') ->setparameter('competitionseason', $competitionseason) ->setparameter('user', $user); if (isset($limit)) { $qb->setmaxresults($limit); } return $qb->getquery()->getoneornullresult();
some idea ?
thanks
as sum
aggregation function result 1 row, limit statement applied afterwards. need create subquery producing multiple rows generalpoints
, coefficient
, limit number of rows in subquery , use aggregation function in wrapping query.
Comments
Post a Comment