Skip to content

Commit d6265bf

Browse files
authored
Merge pull request #111833 from timsander1/master
add order by composite index behavior
2 parents 8413666 + 5b3f5fa commit d6265bf

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

articles/cosmos-db/sql-query-order-by.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ description: Learn about SQL ORDER BY clause for Azure Cosmos DB. Use SQL as an
44
author: timsander1
55
ms.service: cosmos-db
66
ms.topic: conceptual
7-
ms.date: 02/12/2020
7+
ms.date: 04/17/2020
88
ms.author: tisande
99

1010
---
1111
# ORDER BY clause in Azure Cosmos DB
1212

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.
1414

1515
## Syntax
1616

@@ -26,9 +26,9 @@ ORDER BY <sort_specification>
2626

2727
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.
2828

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.
3030

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.
3232

3333
- `<sort_expression>`
3434

@@ -40,7 +40,7 @@ ORDER BY <sort_specification>
4040

4141
- `ASC | DESC`
4242

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.
4444

4545
## Remarks
4646

@@ -147,7 +147,7 @@ The results only include the document that has a defined `lastName`:
147147
]
148148
```
149149

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.
151151

152152
Here is a sample indexing policy which allows you to have documents with an undefined `lastName` appear in the query results:
153153

0 commit comments

Comments
 (0)