Home

Getting Started

Utilities

Indexing

Omnidex

Development

Tutorials

Quick Links

 

SQL Reference

SELECT Statement

Syntax

SELECT List

FROM

WHERE

GROUP BY / HAVING

ORDER BY

Criteria Conditioning

 

SQL Reference

Joins

Nested Queries

Set Operations

ON CURSOR | INSTANCE

WITH Options

Commands

Functions

 

ORDER BY Clause

Column Names

Column Alias

Select List Item Ordinal Numbers

Aggregates, Functions, Expressions

ASC, DESC

 

Column Names

SELECT company, contact, phone FROM customers ORDER BY company

SELECT company, contact, phone FROM customers ORDER BY company, contact

SELECT company, contact, phone FROM customers ORDER BY state

 

Column Alias

SELECT company CO, contact CT, phone PH FROM customers ORDER BY CO

SELECT company, contact, phone FROM customers ORDER BY CO, CT

 

Select List Item Ordinal Numbers

SELECT company, contact, state FROM customers ORDER BY 3

SELECT company, contact, state FROM customers ORDER BY 3, 1

 

Aggregates, Functions, Expressions

SELECT customer_no, sum(amount) FROM orders GROUP BY customer_no ORDER BY 2

SELECT customer_no, count(distinct order_no) FROM orders GROUP BY customer_no
ORDER BY 2, 1

 

ASC, DESC

DESC (Descending) sorts will NOT be optimized, meaning they may increase the overall elapsed query time. ASC (Ascending) sorts may be optimized, depending on the index installation.

SELECT company, contact, phone FROM customers ORDER BY company asc

SELECT customer_no, count(distinct order_no) FROM orders GROUP BY customer_no
ORDER BY 2 DESC, 1 ASC

 

Top