1

I can't filter my results with andHaving condition, because AVG function returns string values.

 $qb = $this->getDoctrine()->getRepository('AppBundle:Service')->createQueryBuilder('s');
 $qb->join('s.ratingList', 'r')
    ->addSelect('AVG(r.rating) as avg_rating')
    ->addGroupBy('s.service')
    ->andHaving('avg_rating >= :rating')
    ->setParameter('rating', $rating)
  ;

In results see that avg_rating is string format not number, that's why filtering doesn't work. Now how can I get avg_rating as integer?

blahblah
  • 1,010
  • 15
  • 40

0 Answers0