I got this Doctrine query:
select upper(substring(e.name, 1, 1)) first_letter
from Application\\Models\\Exercise e
group by first_letter
My guess is that it is looking for first_letter to be an Entity. This is similar problem in some sql queries where you can't use a computed attribute from the select statement as criteria. Try the following:
select upper(substring(e.name, 1, 1)) first_letter
from Application\Models\Exercise e
group by upper(substring(e.name, 1, 1))
order by upper(substring(e.name, 1, 1)) asc