About ORDER BY

1-10 of 200Refresh
Manual
503

ORDER BY clause (JPQL / Criteria API)

The ORDER BY clause specifies a required order for the query results. Any JPQL query that does not include an ORDER BY clause produces results in an undefined and non-deterministic order. ORDER BY ... is at least one million people, ordered by the country name: SELECT c.name FROM Country c WHERE c.population > 1000000
Manual
226

GROUP BY and HAVING clauses

The GROUP BY clause enables grouping of query results. A JPQL query with a GROUP BY clause returns properties of generated groups instead of individual objects and fields. The position of a GROUP BY clause in the query execution order is after the FROM and WHERE clauses, but before the SELECT
JDO Doc
79

setOrdering(ordering)

Method javax.jdo.Query void setOrdering(   String ordering ) Set the ordering specification for the result Collection. The ordering specification is a String containing one or more ordering declarations separated by commas. Each ordering declaration is the name of the field on which to order
Forum
48

Problem with distinct select, order by and equivalent alias/attribute path

when ordering the results of some projection when the order by expression is different (though logically ... _location "             + "order by s_location.id asc";         System.out.println("Working query ... "             + "left join s.location as s_location "             + "order by s.location.id asc
Forum
48

java.lang.NullPointerException when using ORDER BY

== 0)) ORDER BY r.startDateTime DESC If we remove the ORDER BY part, the query completes OK ... sure if this problem is related to the other as the query works if you remove the order by ... which is used in the order by part, it always has a value. Anyway, we tried fixing the indices
Forum
47

Strange behaviour with ORDER BY and IN

performance I noticed a strange behaviour where an ORDER BY - directive isn't executed as ... ("Locations without selection criterion in descending order (by id): ");         em.createQuery("select l from Location l order by l.id desc", Location.class)             .getResultList().forEach(l
Forum
47

ORDER BY problem, when String starts with language specific character

Dear all, I have a problem with ORDER BY clause. I have a simple query: select u from User u order by u.name When the name starts with "normal/english" character, records are ordered correctly ... to JPQL and JDOQL) you can use the Normalizer expression directly in the query ORDER BY clause
Forum
47

Cannot sort descending, when ordering by caluculated float in a method

Hi, I have found an issue in ordering by a method. I have two entities : Invoice and InvoiceItem ... ...) select i from Invoice i order by i.getPrice() desc/asc it gives the same order for desc and asc ... .createQuery(             "SELECT i FROM Invoice i ORDER BY i.getPrice() DESC");         List resultList
Forum
46

order by string with numbers

  The sql that works is ORDER BY CAST(SUBSTR(username FROM 4) AS UNSIGNED) ASC Using JPQL SELECT u FROM Users u ORDER BY SUBSTRING(u.username,4)*1 ASC If you have other alternative for JPA ... Hi Anyone could help me I need to order a string  for example user1, user2, ..., user1000 I found
Forum
46

NULL prefered in ORDER BY?

Hi! Is there a way to NOT prefer NULL in Order BY? I.e. assume this: @Entity class Hint ... Test ORDER BY hint.name It orders ASC like this (assuming I've got three Test Entities whereas first ... are smaller than any other value so they appear first in ordering. Please fill a feature request