Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
This NULL values and IS NULL worksheet is part of the WA Computer Science ATAR Year 11 — Data Management journey. Print it as a booklet?
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1SELECT firstName FROM students WHERE house IS NULL; | AlastName VARCHAR(30) NOT NULL | |
| 2SELECT COUNT(points) FROM students; | BReturns the students who have no house recorded, because their house value is missing (NULL). | |
| 3To find rows where a value is missing, you must use IS NULL, because = NULL never matches anything. | CCounts only the students whose points value is not NULL, because aggregates ignore NULL. | |
| 4A NOT NULL constraint stops a column from being left empty when a row is inserted. | D= NULL never matches, because NULL is not a value that can be compared with =. The query returns no rows. It should use WHERE house IS NULL. | |
| 5SELECT * FROM students WHERE house = NULL; | EWHERE mark IS NULL | |
| 6SELECT * FROM students WHERE house = ''; | FThis tests for a blank text value, not NULL. A missing house is NULL, which is different from an empty string, so the rows are missed. It should use WHERE house IS NULL. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
IS NULL — NULL marks a missing value. Test for it with IS NULL or IS NOT NULL, because = NULL never matches. NULL is not a blank or 0, and aggregates ignore it.SELECT firstName FROM students WHERE house
IS NULL;SELECT * FROM products WHERE price IS NOT
NULL;CREATE TABLE club (
name TEXT NOT NULL
);-- Students who have a points value
SELECT COUNT(points) FROM students;-- house is blank text, not NULL
SELECT * FROM students WHERE house = '';