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
round-pushpin Returns the Word records ordered ascending by Text.
SELECT
    Id, Text, LanguageId
FROM
    WordList:Word
WHERE
    Text LIKE 'Summar%'
ORDER BY
    Text

round-pushpin Also returns the Word records ordered ascending by Text.
SELECT
    Id, Text, LanguageId
FROM
    WordList:Word
WHERE
    Text LIKE 'Summar%'
ORDER BY
    Text ASC

round-pushpin Returns the Word records ordered descending by Text.
SELECT
    Id, Text, LanguageId
FROM
    WordList:Word
WHERE
    Text LIKE 'Summar%'
ORDER BY
    Text DESC

round-pushpin 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