Quick Search:
CODE
Oracle PL/SQL Code Library
JOBS
Find Or Post Oracle Jobs
FORUM
Oracle Discussion & Chat
 Oracle PL/SQL: ORDER BY Clause Jump to:  
Category: >> Oracle PL/SQL >> ORDER BY Clause Bookmark and Share

<< 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; 
 
 
 
 
 


Free
Oracle Magazine
Subscriptions
and Oracle White Papers


SQL University.net courses meet the most demanding needs of the business world for advanced education in a cost-effective manner. SQL University.net courses are available immediately for IT professionals and can be taken without disruption of your workplace schedule or processes.

Compared to traditional travel-based training, SQL University.net saves time and valuable corporate resources, allowing companies to do more with less. That's our mission, and that's what we deliver.

Click here to find out more
 
Home      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 60 users online    © 2009 psoug.org

PSOUG LOGIN
Username: 
Password: 
Forgot your password?