Order By



ORDER BY sorts the results, ascending (ASC, the default) or descending (DESC), by one or more fields, expressions or aggregate functions.

Notes on result limiters

When using Top or Offset, the ORDER BY is applied before the rows are limited.


round-pushpin Orders the words ascending by Text.
SELECT Id, Text, LanguageId FROM WordList:Word WHERE Text LIKE 'Summar%' ORDER BY Text

round-pushpin Orders by LanguageId ascending and then by Text descending.
SELECT
    Id, Text, LanguageId
FROM
    WordList:Word
ORDER BY
    LanguageId ASC,
    Text DESC

round-pushpin Orders by an expression.
SELECT Text FROM WordList:Word WHERE LanguageId = 1 ORDER BY Length(Text) DESC

round-pushpin Orders groups by an aggregate.
SELECT LanguageId, Count(0) as Words FROM WordList:Word GROUP BY LanguageId ORDER BY Count(0) DESC




SQL :: Mean
Returns the arithmetic mean of the values in each group (the same as Avg).
SQL :: Median
Returns the median (middle) value in each group. For an even number of values it is the average of the two middle values.
SQL :: Min
Returns the smallest numeric value in each group. Use MinString for text.
SQL :: MinString
Returns the alphabetically smallest value in each group.
SQL :: Mode
Returns the value that occurs most often in each group. When several values are tied, the first one encountered is returned.
SQL :: Offset
Skips a number of rows of an ordered result, for paging.
SQL :: Select
Select statements are used to read (or query) data from the database.
SQL :: Sha1Agg
Returns a single SHA-1 hash of all of the values in each group, as a lower case hex string. Useful for detecting changes to a set of documents.
SQL :: Sha256Agg
Returns a single SHA-256 hash of all of the values in each group, as a lower case hex string. Useful for detecting changes to a set of documents.
SQL :: Sha512Agg
Returns a single SHA-512 hash of all of the values in each group, as a lower case hex string. Useful for detecting changes to a set of documents.