Numbers: bigger, smaller, between
Pick books by number: from a year on, or between two years.
Use >, <, >= and BETWEEN in WHERE. Numbers have no quotes.
Show the title and year of the books published from 1950 to 1999 (both included).
| book_id | title | author | genre | year | pages |
|---|---|---|---|---|---|
| 1 | Gone Girl | Gillian Flynn | Thriller | 2012 | 419 |
| 2 | Angels & Demons | Dan Brown | Thriller | 2000 | 616 |
| 3 | The Fellowship of the Ring | J.R.R. Tolkien | Fantasy | 1954 | 423 |
| 4 | Pride and Prejudice | Jane Austen | Romance | 1813 | 432 |
| 5 | Charlotte's Web | E.B. White | Children | 1952 | 184 |
| 6 | Harry Potter and the Prisoner of Azkaban | J.K. Rowling | Fantasy | 1999 | 317 |
| 7 | Mockingjay | Suzanne Collins | Science Fiction | 2010 | 390 |
| 8 | The Time Machine | H.G. Wells | Science Fiction | 1895 | 118 |
| 9 | The Lion, the Witch and the Wardrobe | C.S. Lewis | Fantasy | 1950 | 172 |
| 10 | Frankenstein | Mary Shelley | Horror | 1818 | 280 |
Run your query to see the result table.
Press the green Run button or Ctrl+Enter.
How BETWEEN works
Which comparisons are there?
=equal,<>not equal (!=works too),>bigger,<smaller,>=bigger or equal,<=smaller or equal.Does "2000 or later" include 2000?
Yes, so it's
year >= 2000.year > 2000leaves out a book from exactly 2000. Words like "at least", "or more" and "up to" all include the limit.What does
BETWEENdo?WHERE year BETWEEN 1950 AND 1999It keeps values from 1950 to 1999, and both ends are included. It's the same as
year >= 1950 AND year <= 1999.Do numbers need quotes?
No:
year >= 2000, notyear >= '2000'. Quotes are for text.How is this like Excel?
The same test as
=IF(E2>=2000, ...), or a number filter on the year column.
Know someone fighting with a spreadsheet? Send them this page.