This is an old revision of the document!


DRAFT

Omnidex SQL: SELECT ORDER BY Clause

Description

ORDER BY Clause

The ORDER BY clause returns selected rows in ascending or descending order by the specified column_spec or the ordinal position of a column_spec in the column list.

select trans_date, trans_amount from trans_table order by trans_date;
select trans_date, trans_amount from trans_table order by 2;

The column_spec can be in the format of [database.][table.]column or table_alias.column.

select trans_date, trans_amount from trans_table order by db1.trans_table.trans_amount;

Column_spec can also be prefixed with an alias name of the table's column or an alias name of an expression.

select trans_date, trans_amount - discount NetAmount from trans_table order by NetAmount;

The ASC/DESC modifier can be used to return the data in ascending or descending order with ascending order being the default.

select trans_date, trans_amount from trans_table order by trans_date desc;

Syntax

Statement

Discussion

arg1
arg2

Examples

Simple

2nd example

 
Back to top
dev/sql/statements/select/order_by.1278192492.txt.gz ยท Last modified: 2016/06/28 22:38 (external edit)