I was trying make this query by PHQL:
$query = $this->modelsManager->createQuery("select team, sum(case when used = 0 and team = 2 then points end) totalpoints from Genkeys join Tasks on Genkeys.uloha = Tasks.id group by team");
$Genkeys = $query->execute();
foreach ($Genkeys as $genkey) {
$this->view->disable();
var_dump($genkey);
}
Whe I tryed that in phpmyadmin as raw sql it was working fine but when I run it in controller I see this error:
Syntax error, unexpected token IDENTIFIER(when), near to ' used = 0 and team = 2 then points end) totalpoints from Genkeys join Tasks on Genkeys.uloha = Tasks.id group by team', when parsing: select team, sum(case when used = 0 and team = 2 then points end) totalpoints from Genkeys join Tasks on Genkeys.uloha = Tasks.id group by team (143)