Filtering III — Special Comparison Operators 5 of 8 · Comparing with Missing Values

The instruction on this exercise is not clear
What am I supposed to do?

Filtering III — Special Comparison Operators

5 of 8 · Comparing with Missing Values

Learn

Let’s display some of the columns in employee.

employee_id last_name first_name title reports_to
1 Adams Andrew General Manager
2 Edwards Nancy Sales Manager 1
3 Peacock Jane Sales Support Agent 2
4 Park Margaret Sales Support Agent 2
5 Johnson Steve Sales Support Agent 2
6 Mitchell Michael IT Manager 1
7 King Robert IT Staff 6
8 Callahan Laura IT Staff 6

Before looking at the results, try to determine the result of the following query.

SELECT employee_id, last_name, first_name, title, reports_to

FROM employee

WHERE reports_to <> 1;

Copy

Have you thought about it? How many rows are there in the result? Let’s see . . .

employee_id last_name first_name title reports_to
3 Peacock Jane Sales Support Agent 2
4 Park Margaret Sales Support Agent 2
5 Johnson Steve Sales Support Agent 2
7 King Robert IT Staff 6
8 Callahan Laura IT Staff 6

We got five rows! Did it match what you had in mind? What happened to the very first row?

employee_id last_name first_name title reports_to
1 Adams Andrew General Manager

Shouldn’t a “missing value” be different from 1?

We’ll learn what’s going on here in the next couple of screens. For now, let’s extrapolate from what we saw above to solve an exercise.

Instructions

  1. Run the following query and observe the results.
SELECT customer_id, first_name, last_name, fax
  FROM customer

This is the LEARN I’m not sure what they need from this exercise

It seems not all the instructions appeared to you, they should read:

  1. Run the following query and observe the results.

    SELECT customer_id, first_name, last_name, fax
      FROM customer;
    
  2. Given that all values in the fax column are either missing or start with a +, how many rows would the query return if we added the following WHERE statement to it?

    WHERE SUBSTRING(fax, 1, 1) <> '+';
    
  3. To answer the question, write SELECT <answer>; replacing <answer> with the number of rows you think the query will return. For example, if you think that the query returns 2 rows, write SELECT 2;.

2 Likes

Okay, thank you very much

1 Like