Brightlane's data quality team is auditing incomplete customer profiles ahead of a CRM migration to a new system.
Write a query to return the name and email of every customer whose city has not been recorded.
Assumptions:
- The
customerstable contains every customer Brightlane has on file. - Some customers have a recorded
cityvalue; others havecityset toNULL. - A missing city is stored as
NULL, not as an empty string.
Output:
- One row per customer with no city on file, with columns
nameandemail.
Schema · ecommerce 5 tables
Run previews · Check grades
Write a query, then run it to see results here.
Worked solution Try it yourself first
SELECT
name,
email
FROM
customers
WHERE
city IS NULL The shape
IS NULL is the only operator that detects a missing value. The CRM audit wants every customer with no city on file, so the WHERE clause asks that question directly.
Clause by clause
SELECT name, emailreturns the two columns the audit needs — the customer's name and how to reach them.cityitself stays out of the output; it'sNULLfor every row in the result.FROM customersreads the customer records. The prompt's assumption that this table contains every customer Brightlane has on file is what makes the result complete.WHERE city IS NULLkeeps only rows whosecityis absent.IS NULLreturnstruefor those rows andfalsefor everyone with a city recorded.
The trap
WHERE city = NULL looks like it should work and returns zero rows every time. Comparing anything to NULL with = produces unknown, never true, and WHERE only keeps rows whose condition is clearly true. The query runs without error, the result comes back empty, and the audit silently misses every account it was supposed to find. Use IS NULL whenever the test is for absence.
You practiced testing for the absence of a value with IS NULL. The = operator can't match NULL — IS NULL is the only correct test for missing data.