PL/SQL Order By

The ORDER BY clause is used to order rows returned in an select statement.
With ORDER BY clause you can use parameters ASC or DESC to specify ascending order and descending order.

Order By example

 
SELECT * FROM course ORDER BY price, name;

SELECT * FROM course ORDER BY price ASC, name ASC;

SELECT * FROM course ORDER BY 5, 2;

Output is the same for all 3 select statements

COURSE_IDNAMEDESCRIPTIONDURATIONPRICE
3HTML5Learn HTML 51 week10
1SQL 1SQL course for beginners1 week10
5CSSLearn CSS2 week20
2SQL 2SQL course for advanced2 week50
4PHPPHP course4 week75

Order By example

 
SELECT o.order_id, s.student_id, s.first_name, s.last_name
FROM students s, 
(SELECT * FROM orders ORDER BY order_id DESC) o
WHERE s.student_id=o.student_id
AND ROWNUM=1;

Output

ORDER_IDSTUDENT_IDFIRST_NAMELAST_NAME
224EmilyPETERSON