How to use case when in a query

I have this query:

$em = $this->getDoctrine()->getEntityManager(); $query = $em->createQuery("SELECT u,COUNT(u) AS nb_renouvellement, SUM(CASE WHEN f.`Criticity` = 'M' THEN 1 ELSE 0 END) nb_majeur, SUM(CASE WHEN f.`Criticity` = 'C' THEN 1 ELSE 0 END) nb_critique FROM AdminBlogBundle:AlertesBss2 f GROUP BY f.BSC"); $listes = $query->getResult(); 

but i have this error

[Syntax error] line 0, col 45: Error: Expected letters received by "CASE"

+4
source share
1 answer

Criticality should not be in quotation marks, and it should be a group by fu

-1
source

Source: https://habr.com/ru/post/1441253/


All Articles