ORDER BY

<< Click to Display Table of Contents >>

Navigation:  Apollo SQL > DDL & DML Statements >

ORDER BY

 

ORDER BY clause is optional.

Single fields listed in SELECT clause can be used in ORDER BY clause.

Multi-columns sort is supported.

If an expression is defined in SELECT clause for one column, then you must refer to that column by its ordinal position (starting from 1 for first column) or by its alias.

ASC/DESC are fully supported

Examples:

SELECT firstname, lastname, phone FROM customer ORDER BY firstname, lastname

 

SELECT * FROM requests ORDER BY req_date DESC

 

SELECT * FROM credits ORDER BY lastname, firstname, born_date DESC

 

SELECT Sales + Bonus As TotalSales FROM customers ORDER BY TotalSales DESC

 

SELECT Length / 2.54 As Inches, Area, Perimeter FROM Lots

ORDER BY 1 DESC, Area ASC, 3