/
ORDER BY Clause
ORDER BY Clause
The ORDER BY clause is used to specify the order of the output data.
SELECT * FROM [customer] ORDER BY [name]
Use the additional operators ASC and DESC to specify whether the results should be sorted in ascending or descending order. Without additional operators, the results are sorted in ascending order (ASC) by default.
SELECT * FROM [customer] ORDER BY [name] DESC
For the ORDER BY clause to also meet more complex demands, you can enter several element types for sorting.
SELECT [products].[name], [products].[priceperitem] FROM [products] WHERE [products].[priceperitem] <= 200 ORDER BY [products].[priceperitem] DESC, [products].[name]
Using the ORDER BY clause is only possible in the outermost query, not in subselects and not in partial queries linked by UNION or EXCEPT.
, multiple selections available,
Related content
TOP Clause
TOP Clause
More like this
Addressing Columns Using Their Number
Addressing Columns Using Their Number
More like this
WHERE Clause
WHERE Clause
More like this
FROM Clause
FROM Clause
More like this
Scenarios for Business Objects and Relations
Scenarios for Business Objects and Relations
More like this
UNION and EXCEPT
UNION and EXCEPT
More like this