Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] Aggregate Functions in ORDER BY

is it possible to do something like this?


        return em.createQuery("SELECT new itrac.data.WebHotlist(MAX(a.date) as maxdate, c) " +
                              "FROM Activity a INNER JOIN a.cookieid cookie " +
                              "INNER JOIN cookie.contactidCollection c " +
                              "INNER JOIN c.listidCollection l " +
                              "WHERE l.userid = :user " +
                              "AND a.companyid = :company " +
                              "AND a.date BETWEEN :start AND :end " +
                              "GROUP BY c " +
                              "ORDER BY MAX(a.date) DESC")

                          .setParameter("user", user)
                          .setParameter("company", user.getCompanyid())
                          .setParameter("start", start)
                          .setParameter("end", end)
                          .getResultList();


if not, is it best to use a sorted collection, and make the WebHotlist comparable?

Back to the top