Order By



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.


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





SQL :: Top
The top keywork limits the number of results that are returned by a query.
SQL::Keywords
A breakdown of all high-level statements available via the query handler.