Я пытаюсь получить список изображений в галерее, сумму оценок и количество избирателей. Я делаю sql запрос:
SELECT img.id, img.title, img.image, img.thumb, img.link, img.published,
rating.sum, rating.voters
FROM AcmeMainBundle:Category cat, AcmeMainBundle:User usr, AcmeMainBundle:Image img
LEFT OUTER JOIN
(
SELECT SUM(r.rating) as sum, COUNT(r.rating) as voters, r.image
FROM AcmeMainBundle:ImgRating r
) AS rating ON rating.image = img.id
WHERE usr.username = :user AND cat.user = usr.id AND
cat.id = :category AND img.category = cat.id
ORDER BY img.order ASC, img.id DESC
но я получаю исключение:
[Semantical Error] line 0, col 253 near 'SELECT SUM(r.rating)': Error:
Identification Variable ( used in join path expression but was not defined before.