Order By
Overview
Order by allows you to sort a result-set (either ascending or descending) by a given set of fields.
Notes on result limiters
When using a limiter such as TOP, the ORDER BY is executed before the limiter.Example
Returns the Word records ordered ascending by Text.
SELECT
Id, Text, LanguageId
FROM
WordList:Word
WHERE
Text LIKE 'Summar%'
ORDER BY
Text
Also returns the Word records ordered ascending by Text.
SELECT
Id, Text, LanguageId
FROM
WordList:Word
WHERE
Text LIKE 'Summar%'
ORDER BY
Text ASC
Returns the Word records ordered descending by Text.
SELECT
Id, Text, LanguageId
FROM
WordList:Word
WHERE
Text LIKE 'Summar%'
ORDER BY
Text DESC
Returns the Word records ordered ascending by LanguageId and descending by Text.
SELECT
Id, Text, LanguageId
FROM
WordList:Word
WHERE
Text LIKE 'Summar%'
ORDER BY
LanguageId ASC,
Text DESC
See also
Related
- Keywords - A breakdown of all high-level statements available via the query handler.