Open these in Waypoints Prepare with one click. To share a file another way, copy its address and paste it into Load URL, or download the file and import it. In Prepare, the worksheet's Teacher edition shows the answers; the student copy hides them.
WorksheetOpen in PrintDownload Print the student copy; the Teacher edition has the answers.
Students will be able to
I can keep only some rows with WHERE.
I can say why text needs quotes and a column name does not.
I can compare a number column with > or <.
Timing
Predict and Run 8 min · Investigate 8 min · Modify and Make 9 min
Running the lesson
Predict: the error option catches students who think pop must be a column.
Run: change the genre and run again, then ask what happens with a genre that does not exist (no rows, no error).
Investigate: the quotes question is the main idea. Ask what SQL does with a word that has no quotes.
In class
On the slides at these points. Students can do the whole lesson on their own; these are for the room. In the deck, the Run, Modify and Make slides have the live playground in them (the tutorial link is the backup), and the notes above are in each slide's speaker notes.
Human filter(end, 3 min)
Read out WHERE tests (such as year > 2020). Students stand if the song on their card passes the test.
The hard part (on purpose)
Quotes. Ask: is this word a column or a value? Columns have no quotes; text values do.
When students get stuck
What you will see
A question to ask
The fix
no such column: pop
Is pop a column, or a value in a column?
Put single quotes round the text value.
No rows come back.
How is the genre spelled in the table?
Match the spelling in the data. Text must match letter for letter.
Answers to the checks
Predict: Four of the 15 songs are pop. What will this show? 4 rows. WHERE tests every row and keeps only those where the test is true.
Count the long songs: Run the query. How many songs are longer than 250 seconds? 4
Quotes: Why does WHERE genre = pop (no quotes) give an error? pop looks like a column name Without quotes, pop looks like a column name, and there is no such column. Quotes make a value of text. Without them SQL thinks pop is the name of a column.
Write the test: Which query finds songs released after 2021? SELECT title FROM songs WHERE year > 2021; A test has a column, a comparison and a value: year > 2021.
Solutions
One possible solution for each task. Other correct programs are fine.
Modify
SELECT title
FROM songs
WHERE artist = 'Kito';
Make
SELECT title, plays
FROM songs
WHERE plays > 5000;
Stretch and support
Stretch: Combine two tests (next lesson uses AND) or try year >= 2022.
Support: Give the WHERE line with the value missing.
Exit ticket
What does WHERE do, and why is 'pop' in quotes?
It keeps only the rows where the test is true. Quotes show that pop is a value, not a column.
What each step is for
Investigate: WHERE is a test applied to each row. Text values go in quotes, numbers do not, and the columns you show can differ from the column you test.
Where it leads
Next lesson: put the rows in order and show only the top few.