我有以下 dql SELECT 查询,该查询有效:
SELECT q AS question, AVG(r.score) AS average
FROM MyBundle:Question q
JOIN q.ratings r
WHERE q.deleted IS NULL
GROUP BY q.id
ORDER BY q.id ASC
AVG(r.score)
如果是 0 或 null ,我想做的是让它返回 0 。我只是不知道该怎么做。是否可以执行以下操作:
SELECT q AS question, (AVG(r.score) OR 0) AS average FROM....