In: Computer Science
When using the ORDER BY statement, the keywords: ASC, or DESC must be used to control the sort order. The ORDER BY statement will not work without a designated sort order keywords.
The ORDER BY statement in sql is used to sort the fetched data in either ascending or descending order and the keyword ASC to sort in Ascending order.
syntax: SELECT * FROM table_name ORDER BY column_name ASC| DESC
ASC : to sort the data in ascending order
DESC : to sort the data in descending order
Sort according to multiple columns: SELECT * FROM Student ORDER BY Age ASC, ROLL_NO DESC;
If you don't specify the ASC or DESC keyword, SQLite sorts the results set using the ASC option. It sorts the results set in the ascending order by default.
The SELECT statement that does not use ORDER BY clause returns a result set that is not in any order.
The addition ORDER BY sorts a multiple results set of a query by the content of the specified columns. The order of the rows in the results set is undefined with respect to all columns that are not specified after ORDER BY, and can be different in repeated executions of the same SELECT statement. If the addition ORDER BY is not specified, the order of all the columns in the results set is undefined.