+

Search Tips   |   Advanced Search

ORDER BY clause

The ORDER BY clause specifies an ordering of the objects in the result collection

Use the syntax:

ORDER BY  [ order_element ,]* order_element
order_element ::= { path-expression | integer } [ ASC | DESC ]

The path expression must specify a single valued field that is a primitive type of byte, short, int, long, float, double, char or a wrapper type of Byte, Short, Integer, Long, Float, Double, BigDecimal, String, Character, java.util.Calendar, java.util.Date, java.sql.Date, java.sql.Time, java.sql.Timestamp.

ASC specifies ascending order and is the default. DESC specifies descending order.

Integer refers to a selection expression in the SELECT clause.


Example: ORDER BY clause

Return department objects in decreasing deptno order:

Return employee objects sorted by department number and name:


Related concepts

  • EJB query language


    Related tasks

  • Use EJB query
  • Use the dynamic query service