An ORDER BY clause in SQL specifies that a SQL SELECT statement returns a result set with the rows being sorted by the values of one or more columns. The sort criteria does not have to be included in the result set (restrictions apply for SELECT DISTINCT, GROUP BY, UNION [DISTINCT], EXCEPT [DISTINCT] and INTERSECT [DISTINCT].) The sort criteria can be expressions, including column names, user-defined functions, arithmetic operations, or CASE expressions. The expressions are evaluated and the results are used for the sorting, i.e., the values stored in the column or the results of the function call.
ORDER BY is the only way to sort the rows in the result set. Without this clause, the relational database system may return the rows in any order. If an ordering is required, the ORDER BY must be provided in the SELECT statement sent by the application. Although some database systems allow the specification of an ORDER BY clause in subqueries or view definitions, the presence there has no effect on the final result-set order, but makes sense when combined with a result offset clause or a fetch first clause. A view is a logical relational table, and the relational model mandates that a table is a set of rows, implying no sort order whatsoever. The only exception are constructs like ORDER BY ORDER OF ... (not standardized in SQL:2003) which allow the propagation of sort criteria through nested subqueries.
The SQL standard's core functionality does not explicitly define a default sort order for Nulls. With the SQL:2003 extension T611, "Elementary OLAP operations", nulls can be sorted before or after all data values by using the NULLS FIRST or NULLS LAST clauses of the ORDER BY list, respectively. Not all DBMS vendors implement this functionality, however. Vendors who do not implement this functionality may specify different treatments for Null sorting in the DBMS.[1]
Structure ORDER BY ... DESC will order in descending order, otherwise ascending order is used. (The latter may be specified explicitly using ASC.)
^"NULL Handling in SQLite Versus Other Database Engines". Retrieved January 25, 2009.
An ORDERBY clause in SQL specifies that a SQL SELECT statement returns a result set with the rows being sorted by the values of one or more columns....
The Most Excellent Order of the British Empire is a British order of chivalry, rewarding contributions to the arts and sciences, work with charitable and...
The Most Honourable Order of the Bath is a British order of chivalry founded by King George I on 18 May 1725. The name derives from an elaborate medieval...
The Order of Preachers (Latin: Ordo Praedicatorum; abbreviated OP), also known as the Dominican Order, is a Catholic mendicant order of pontifical right...
The Most Noble Order of the Garter is an order of chivalry founded by Edward III of England in 1348. The most senior order of knighthood in the British...
14 February 1975 by Elizabeth II, Queen of Australia, on the advice of the Australian Government. Before the establishment of the order, Australian citizens...
The Teutonic Order is a Catholic religious institution founded as a military society c. 1190 in Acre, Kingdom of Jerusalem. The Order of Brothers of the...
Look up order or Order in Wiktionary, the free dictionary. Order, ORDER or Orders may refer to: A socio-political or established or existing order, e.g....
A gag order (also known as a gagging order or suppression order) is an order, typically a legal orderby a court or government, restricting information...
In linguistics, word order (also known as linear order) is the order of the syntactic constituents of a language. Word order typology studies it from...
well as efforts by non-Canadians who have made the world better by their actions. Membership is accorded to those who exemplify the order's Latin motto,...
The Order may refer to: The Order (comics), the name of two fictional comic-book superhero teams in the Marvel Comics universe The Order: 1886, a video...
Channel. 28 December 2018. "OrderOrder Out Of Order Movie Review {3.0/5}: Critic Review of OrderOrder Out Of Orderby Times of India". Times of India...
The Order of Jamaica is the fifth of the six orders in the Jamaican honours system. The Order was established in 1969, and it is considered the equivalent...
A court order is an official proclamation by a judge (or panel of judges) that defines the legal relationships between the parties to a hearing, a trial...
Livonian Order was an autonomous branch of the Teutonic Order, formed in 1237. From 1435 to 1561 it was a member of the Livonian Confederation. The order was...
The Doric order was one of the three orders of ancient Greek and later Roman architecture; the other two canonical orders were the Ionic and the Corinthian...
orders of merit: the Order of the Niger and the Order of the Federal Republic. The two highest honours, the Grand Commander in the Order of the Federal Republic...
Alphabetical order is a system whereby character strings are placed in order based on the position of the characters in the conventional ordering of an alphabet...
A restraining order or protective order, is an order used by a court to protect a person in a situation often involving alleged domestic violence, child...
lexicographic or lexicographical order (also known as lexical order, or dictionary order) is a generalization of the alphabetical order of the dictionaries to sequences...
mathematics, a total order or linear order is a partial order in which any two elements are comparable. That is, a total order is a binary relation ≤...
Orange Institution, commonly known as the Orange Order, is an international Protestant fraternal order based in Northern Ireland and primarily associated...
An order book is the list of orders (manual or electronic) that a trading venue (in particular stock exchanges) uses to record the interest of buyers...
a more trusted method of payment than a cheque. The money order system was established by a private firm in Great Britain in 1762 and was expensive and...