I got this Doctrine query:
select upper(substring(e.name, 1, 1)) first_letter from Application\\Models\\Exercise e group by first_letter
I know you've answered this question yourself but just wondering if you tried using DISTINCT:
DISTINCT
select DISTINCT upper(substring(e.name, 1, 1)) first_letter from Application\Models\Exercise e order by e.name asc
Ordering by e.name is equivalent to first_letter in this case.
e.name
first_letter