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-keywords.md
+8-7Lines changed: 8 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,24 +4,25 @@ description: Learn about SQL keywords for Azure Cosmos DB.
4
4
author: markjbrown
5
5
ms.service: cosmos-db
6
6
ms.topic: conceptual
7
-
ms.date: 06/20/2019
7
+
ms.date: 03/17/2020
8
8
ms.author: mjbrown
9
9
10
10
---
11
11
# Keywords in Azure Cosmos DB
12
+
12
13
This article details keywords which may be used in Azure Cosmos DB SQL queries.
13
14
14
15
## BETWEEN
15
16
16
-
As in ANSI SQL, you can use the BETWEEN keyword to express queries against ranges of string or numerical values. For example, the following query returns all items in which the first child's grade is 1-5, inclusive.
17
+
You can use the `BETWEEN` keyword to express queries against ranges of string or numerical values. For example, the following query returns all items in which the first child's grade is 1-5, inclusive.
17
18
18
19
```sql
19
20
SELECT*
20
21
FROMFamilies.children[0] c
21
22
WHEREc.grade BETWEEN 1AND5
22
23
```
23
24
24
-
Unlike in ANSI SQL, you can also use the BETWEEN clause in the FROM clause, as in the following example.
25
+
You can also use the `BETWEEN` keyword in the `SELECT` clause, as in the following example.
25
26
26
27
```sql
27
28
SELECT (c.grade BETWEEN 0AND10)
@@ -31,11 +32,11 @@ Unlike in ANSI SQL, you can also use the BETWEEN clause in the FROM clause, as i
31
32
In SQL API, unlike ANSI SQL, you can express range queries against properties of mixed types. For example, `grade` might be a number like `5` in some items and a string like `grade4` in others. In these cases, as in JavaScript, the comparison between the two different types results in `Undefined`, so the item is skipped.
32
33
33
34
> [!TIP]
34
-
> For faster query execution times, create an indexing policy that uses a range index type against any numeric properties or paths that the BETWEEN clause filters.
35
+
> For faster query execution times, create an indexing policy that uses a range index type against any numeric properties or paths that the `BETWEEN` clause filters.
35
36
36
37
## DISTINCT
37
38
38
-
The DISTINCT keyword eliminates duplicates in the query's projection.
39
+
The `DISTINCT` keyword eliminates duplicates in the query's projection.
39
40
40
41
In this example, the query projects values for each last name:
41
42
@@ -97,7 +98,7 @@ The results are:
97
98
]
98
99
```
99
100
100
-
Queries with an aggregate system function and a subquery with DISTINCT are not supported. For example, the following query is not supported:
101
+
Queries with an aggregate system function and a subquery with `DISTINCT` are not supported. For example, the following query is not supported:
101
102
102
103
```sql
103
104
SELECTCOUNT(1) FROM (SELECT DISTINCTf.lastNameFROM f)
@@ -127,7 +128,7 @@ If you include your partition key in the `IN` filter, your query will automatica
127
128
128
129
## TOP
129
130
130
-
The TOP keyword returns the first `N` number of query results in an undefined order. As a best practice, use TOP with the ORDER BY clause to limit results to the first `N` number of ordered values. Combining these two clauses is the only way to predictably indicate which rows TOP affects.
131
+
The TOP keyword returns the first `N` number of query results in an undefined order. As a best practice, use TOP with the `ORDER BY` clause to limit results to the first `N` number of ordered values. Combining these two clauses is the only way to predictably indicate which rows TOP affects.
131
132
132
133
You can use TOP with a constant value, as in the following example, or with a variable value using parameterized queries.
0 commit comments