SQL BETWEEN

Today’s post is short, but it outlines the SQL BETWEEN Operator.  I’ve been using SQL for many years and I have not used this operator before, but came across it a couple weeks back.  It essentially selects values within a given range, and the values specified are included in the results (i.e. greater than or equal to, less than or equal to).

This SQL Operator works with numbers, text and dates.  There is also a NOT BETWEEN Operator, which can be used to find records outside the range of values specified.

SQL Version:  SQL Server 2014 (Express Edition)

Examples:  SQL BETWEEN

Copy down the following code, then execute to see how the examples work!

Example 1:  Values – Results look like the following, with Vacation Hours ranging between 15 and 20

SQL BETWEEN

Example 2:  Dates – Results look like the following, with Hire Dates ranging between 2003-02-01 and 2003-02-15

SQL BETWEEN

Example 3:  Text – Results look like the following, with Last Names ranging between “Gilbert” and “Ingle”

SQL BETWEEN

 

Additional Content

Check out more examples by visiting my Home Page

Here you will find topics covering  Qlikview  SQL Server  Excel VBA

 

 

Leave a Comment