Doctrine 2: group by field alias (Error: '…' does not point to a Class. )

前端 未结 3 929
无人及你
无人及你 2021-01-23 06:20

I got this Doctrine query:

        select upper(substring(e.name, 1, 1)) first_letter
        from Application\\Models\\Exercise e
        group by first_letter
         


        
3条回答
  •  抹茶落季
    2021-01-23 06:59

    I know you've answered this question yourself but just wondering if you tried using 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.

提交回复
热议问题