BETWEEN

An introduction to the keyword BETWEEN.

The keyword BETWEEN returns a range of data between two values. It can be used with numbers, text strings and dates, and is most commonly found in the WHERE clause.

If we wanted to know what months the animal center took in between 900 and 1000 animals, we could write the following query:

SELECT year,
       month,
       animal_type,
       COUNT
  FROM austin_animal_center_intakes_by_month
 WHERE count BETWEEN 900 AND 2000
 ORDER BY month

And the results would look like:

year month animal_type COUNT
2014 5 Cat 901
2014 5 Dog 966
2015 5 Cat 1009
2015 5 Dog 988
2016 5 Cat 921
2016 5 Dog 1020
2017 5 Cat 914
2015 6 Cat 1103
2015 6 Dog 1014
2014 7 Dog 926
2014 9 Dog 917
2017 9 Dog 943
2013 10 Dog 965
Though it isn’t clearly illustrated by the last query, note that BETWEEN returns everything between two values inclusive of the specified vales.