SQL ORDER BY
Oracle allow data from a table to be viewed in a sorted order. The rows retrieved from the table will be sorted in either ascending or descending order depending on the condition specified in the SELECT statement. Syntax
SELECT * FROM <TableName> ORDER BY <ColumnName1>,<ColumnName2> <[Sort Order]>
The ORDER BY clause will sorts the data based on the column specified after the ORDER BY clause. Note: The ORDER BY clause can only be used in the SELECT statements.
Example for Ascending Order
SELECT * FROM EMPLOYEE ORDER BY FIRSTNAME, LASTNAME ASCE
ORDER BY will sort the data ascending order if we will not specify the any order in the statement
Example for Descending Order
SELECT * FROM EMPLOYEE ORDER BY FIRSTNAME, LASTNAME DESC
Hello! I am Narayanaswamy founder and admin of narayanatutorial.com. I have been working in IT industry more than 7 years. NarayanaTutorial is my web technologies blog. My specialties are Java / J2EE, Spring, Hibernate, Struts, Webservices, PHP, Oracle, MySQL, SQLServer, Web Hosting and Website Development.
I am a self learner and passionate about training and writing. I am always trying my best to share my knowledge through my blog.