DocumentDB SQL Between Keyword - DocumentDB SQL

What is Between Keyword in DocumentDB SQL?

  • To express queries against ranges of values like in SQL the BETWEEN keyword is used. BETWEEN keyword can also be used against strings or numbers.
  • The difference between using BETWEEN in DocumentDB and ANSI SQL is that you can express range queries against properties of mixed types.

For example, it is possible that in some document you will have "grade" as a number and in other documents it might be strings. In this case, comparison between two different types of results is "undefined", and the document will be skipped.

Consider the three documents from the previous example.

The below code is the AndersenFamily document.

The below code is the SmithFamily document.

The below code is the WakefieldFamily document.

Consider an example, where the query returns all family documents in which the first child's grade is between 1-5 (both inclusive).

returns family documents

In the below query, BETWEEN keyword is used and then AND logical operator.

On executing the above code the following result is produced:

To display the grades outside the range of the previous example, use NOT BETWEEN as shown in below query:

On executing the above code the following result is produced:

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

DocumentDB SQL Topics