skip to main content
Expressions, conditions, and queries : Subqueries : ORDER BY clause
 

ORDER BY clause

The ORDER BY clause is used to arrange the result set in an ascending or descending order.

Syntax 

ORDER BY

Example

SELECT empno, deptno FROM emp WHERE deptno in (SELECT TOP 1 deptno FROM dept ORDER BY deptno);
NOTE: OpenAccess SDK returns an error if:
Note: OpenAccess SDK returns an error if The TOP clause is not specified in the subquery along with the ORDER BY clause.
Note: OpenAccess SDK returns an error ifORDER BY is specified in union subqueries. For example: SELECT TOP 1 deptno,empno FROM emp ORDER BY empno UNION SELECT deptno,divno FROM dept;