0 Replies Latest reply on Jul 17, 2006 11:48 AM by Adam Warski

    An EJB-QL query with sorting on an aggregate function

    Adam Warski Master

      I have a problem with constructing a query which uses group-by and sorts by an aggregate column. As I use MySQL, I can't just write "ORDER BY min(column)", so I try a different approach, which works in MySQL, but throws an exception when I try to use it in EJB3. My query looks like this:

      SELECT name, min(dateCreated) AS mdc FROM TagEntity
      GROUP BY name
      ORDER BY mdc

      Any ideas how can I do it any other (working :) ) way?