ORDER BY
The ORDER BY clause is used to sort the records in result set. It can only be used in SELECT statements.
SELECT "column_name"
FROM "table_name"
[WHERE "condition"]
ORDER BY "column_name" [ASC, DESC];
Syntax It is possible to order by more than one column.
ORDER BY "column_name1" [ASC, DESC], "column_name2" [ASC, DESC]
Start-Tech Academy
ORDER BY
The ORDER BY clause is used to sort the records in result set. It can only be used in SELECT statements.
SELECT * FROM customer
WHERE state = 'California’ ORDER BY Customer_name;
Same as
SELECT * FROM customer
WHERE state = 'California’ ORDER BY Customer_name ASC;
Example SELECT * FROM customer
ORDER BY 2 DESC;
SELECT * FROM customer
WHERE age>25 ORDER BY City ASC, Customer_name DESC;
SELECT * FROM customer
ORDER BY age;
Start-Tech Academy