Quick Search:
 
 Oracle PL/SQL: ORDER BY Clause Jump to:  
Category: >> Oracle PL/SQL >> ORDER BY Clause  

<< lastnext >>

Snippet Name: ORDER BY Clause

Description: The ORDER BY clause is used by, and is the last clause of, a SELECT statement.

Comment: (none)

Language:
Highlight Mode: PLSQL
Last Modified: March 16th, 2009

ascending ORDER ON one column -
 
SELECT table_name
FROM user_tables
ORDER BY table_name ASC;
 
ascending ORDER IS the DEFAULT so this can also be written -
 
SELECT table_name
FROM user_tables
ORDER BY table_name;
 
 
ORDER BY descending
 
SELECT table_name
FROM user_tables
ORDER BY table_name DESC;
 
 
ORDER BY Multiple Columns
 
SELECT table_name, tablespace_name
FROM all_tables
ORDER BY tablespace_name, table_name;
 
 
ORDER BY Multiple Columns WITH Mixed Ascending AND Descending 
Orders 
 
SELECT table_name, tablespace_name
FROM all_tables
ORDER BY tablespace_name DESC, table_name; 
 
ORDER BY position
 
Single Column Ascending 
 
SELECT table_name
FROM all_tables
ORDER BY 1; 
 
Single Column Descending 
 
SELECT table_name, tablespace_name
FROM all_tables
ORDER BY 2 DESC; 
 
ORDER BY Multiple Columns 
 
SELECT table_name, tablespace_name
FROM all_tables
ORDER BY 2, 1; 
 
 
 
 
 


 
   Home |    Search |    Code Library |    Sponsors |    Privacy |    Terms of Use |    Contact Us © 2003 - 2024 psoug.org