You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/cosmos-db/sql-query-order-by.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,13 +4,13 @@ description: Learn about SQL ORDER BY clause for Azure Cosmos DB. Use SQL as an
4
4
author: timsander1
5
5
ms.service: cosmos-db
6
6
ms.topic: conceptual
7
-
ms.date: 02/12/2020
7
+
ms.date: 04/17/2020
8
8
ms.author: tisande
9
9
10
10
---
11
11
# ORDER BY clause in Azure Cosmos DB
12
12
13
-
The optional ORDER BY clause specifies the sorting order for results returned by the query.
13
+
The optional `ORDER BY` clause specifies the sorting order for results returned by the query.
14
14
15
15
## Syntax
16
16
@@ -26,9 +26,9 @@ ORDER BY <sort_specification>
26
26
27
27
Specifies a property or expression on which to sort the query result set. A sort column can be specified as a name or property alias.
28
28
29
-
Multiple properties can be specified. Property names must be unique. The sequence of the sort properties in the ORDER BY clause defines the organization of the sorted result set. That is, the result set is sorted by the first property and then that ordered list is sorted by the second property, and so on.
29
+
Multiple properties can be specified. Property names must be unique. The sequence of the sort properties in the `ORDER BY` clause defines the organization of the sorted result set. That is, the result set is sorted by the first property and then that ordered list is sorted by the second property, and so on.
30
30
31
-
The property names referenced in the ORDER BY clause must correspond to either a property in the select list or to a property defined in the collection specified in the FROM clause without any ambiguities.
31
+
The property names referenced in the `ORDER BY` clause must correspond to either a property in the select list or to a property defined in the collection specified in the `FROM` clause without any ambiguities.
32
32
33
33
-`<sort_expression>`
34
34
@@ -40,7 +40,7 @@ ORDER BY <sort_specification>
40
40
41
41
-`ASC | DESC`
42
42
43
-
Specifies that the values in the specified column should be sorted in ascending or descending order. ASC sorts from the lowest value to highest value. DESC sorts from highest value to lowest value. ASC is the default sort order. Null values are treated as the lowest possible values.
43
+
Specifies that the values in the specified column should be sorted in ascending or descending order. `ASC` sorts from the lowest value to highest value. `DESC` sorts from highest value to lowest value. `ASC` is the default sort order. Null values are treated as the lowest possible values.
44
44
45
45
## Remarks
46
46
@@ -147,7 +147,7 @@ The results only include the document that has a defined `lastName`:
147
147
]
148
148
```
149
149
150
-
If we update the container's indexing policy to explicitly include a path for `lastName`, we will include documents with an undefined sort property in the query results. You must explicitly define the path to lead to this scalar value (and not beyond it). You should use the `?` character in your path definition in the indexing policy to ensure that you explicitly index the property `lastName` and no additional nested paths beyond it.
150
+
If we update the container's indexing policy to explicitly include a path for `lastName`, we will include documents with an undefined sort property in the query results. You must explicitly define the path to lead to this scalar value (and not beyond it). You should use the `?` character in your path definition in the indexing policy to ensure that you explicitly index the property `lastName` and no additional nested paths beyond it. If your `Order By` query uses a [composite index](index-policy.md#composite-indexes), the results will always include documents with an undefined sort property in the query results.
151
151
152
152
Here is a sample indexing policy which allows you to have documents with an undefined `lastName` appear in the query results:
0 commit comments