Decode Analytics

View Original

Where Between

The BETWEEN operator selects values within a given range. The between operator is similar to >= AND <=.

SQL Where BETWEEN Syntax:

SELECT  Column1

FROM Table_Name

WHERE Column1 BETWEEN value1 AND value2;


Example:

Lets use the “Orders” table to find all orders placed in the month of September.

See this content in the original post

Results:

See this content in the original post

The NOT Operator can also be used to include all values outside of the selected range while excluding the values in that selected range.

SQL Where NOT BETWEEN Syntax:

SELECT  Column1

FROM Table_Name

WHERE Column1 NOT BETWEEN value1 AND value2;

Example:

Lets use the “Customers” table to exclude all customers whose first name begins with the letters in the range of “N” to “V”.

See this content in the original post



Results:

See this content in the original post

SQL Tutorial

See this content in the original post