Skip to content

Commit e8c7a11

Browse files
authored
Merge pull request #108067 from timsander1/master
adding BETWEEN keyword udpate
2 parents 69055c9 + 0ab12a7 commit e8c7a11

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

articles/cosmos-db/sql-query-keywords.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,25 @@ description: Learn about SQL keywords for Azure Cosmos DB.
44
author: markjbrown
55
ms.service: cosmos-db
66
ms.topic: conceptual
7-
ms.date: 06/20/2019
7+
ms.date: 03/17/2020
88
ms.author: mjbrown
99

1010
---
1111
# Keywords in Azure Cosmos DB
12+
1213
This article details keywords which may be used in Azure Cosmos DB SQL queries.
1314

1415
## BETWEEN
1516

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

1819
```sql
1920
SELECT *
2021
FROM Families.children[0] c
2122
WHERE c.grade BETWEEN 1 AND 5
2223
```
2324

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

2627
```sql
2728
SELECT (c.grade BETWEEN 0 AND 10)
@@ -31,11 +32,11 @@ Unlike in ANSI SQL, you can also use the BETWEEN clause in the FROM clause, as i
3132
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.
3233

3334
> [!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.
3536
3637
## DISTINCT
3738

38-
The DISTINCT keyword eliminates duplicates in the query's projection.
39+
The `DISTINCT` keyword eliminates duplicates in the query's projection.
3940

4041
In this example, the query projects values for each last name:
4142

@@ -97,7 +98,7 @@ The results are:
9798
]
9899
```
99100

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:
101102

102103
```sql
103104
SELECT COUNT(1) FROM (SELECT DISTINCT f.lastName FROM f)
@@ -127,7 +128,7 @@ If you include your partition key in the `IN` filter, your query will automatica
127128

128129
## TOP
129130

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

132133
You can use TOP with a constant value, as in the following example, or with a variable value using parameterized queries.
133134

0 commit comments

Comments
 (0)