Chapter 5. WHERE
Over the next few chapters, we will be adding more functionalities to the
SELECT statement. A very common task when working with data is filtering for records based on criteria, which can be done with a
We will be learning more functions and using them in the
WHERE clause, but we can also use them in
SELECT statements, as discussed in the previous chapter. For the most part, expressions and functions can be used in any part of a SQL statement.
We are going to open another database called
weather_stations. Add this database to your database navigator (refer to Chapter 3 if you’ve forgotten how to do this). Double-click on the database and you will see there is a single table called
STATION_DATA. This contains weather-related sample data gathered from various weather stations.
SELECT on all columns to see the data inside:
There is a lot of data here: about 28,000 records (Figure 5-1). We are not going to glean a lot of interesting information by scrolling through these records one by one. We will need to learn some more SQL features to morph this data into something meaningful. We will start by learning the
WHERE statement, which we can use to filter down records based on a criterion.
Table names and columns can be defined in uppercase or lowercase. ...