Write SQL and Python, run instantly in your browser, and track your progress.
You are a data analyst at Walmart. The product team is planning to launch a new feature that sends SMS notifications for order updates and promotions. To understand the potential reach of this feature, they first need to identify US-based customers whose phone numbers are missing from the database. A clean dataset is crucial before launching the campaign.
Your task is to generate a list of all customers in the 'US' for whom a phone number is missing (NULL), but a state is on file (indicating the account has some location data). The list should include the customer's ID, full name, email, and state, sorted alphabetically by the customer's full name.
| Column Name | Type |
|---|---|
| customer_id |
You are a data analyst at Walmart. The product team is planning to launch a new feature that sends SMS notifications for order updates and promotions. To understand the potential reach of this feature, they first need to identify US-based customers whose phone numbers are missing from the database. A clean dataset is crucial before launching the campaign.
Your task is to generate a list of all customers in the 'US' for whom a phone number is missing (NULL), but a state is on file (indicating the account has some location data). The list should include the customer's ID, full name, email, and state, sorted alphabetically by the customer's full name.
| Column Name | Type |
|---|---|
| customer_id |
| INTEGER |
| INTEGER |
| full_name | TEXT |
| full_name | TEXT |
| TEXT |
| TEXT |
| phone | TEXT |
| phone | TEXT |
| city | TEXT |
| city | TEXT |
| state | TEXT |
| state | TEXT |
| country | TEXT |
| country | TEXT |
| created_at | TEXT |
| created_at | TEXT |
| customer_id | full_name | phone | city | state | country | created_at | |
|---|---|---|---|---|---|---|---|
| 1 | Sophia Lewis | sophia.lewis@gmail.com | San Diego | CA | US | 2024-10-10 19:19:27 |
| customer_id | full_name | phone | city | state | country | created_at | |
|---|---|---|---|---|---|---|---|
| 1 | Sophia Lewis | sophia.lewis@gmail.com | San Diego | CA | US | 2024-10-10 19:19:27 |
| customer_id | full_name | state | |
|---|---|---|---|
| 15 | Chen Mendoza | chen_mendoza@yahoo.com | NC |
| 11 | Denise Huang | deniseh@aol.com | TX |
| 49 | Douglas Moore | douglas.moore@protonmail.com | OH |
| 25 | Douglas Price | douglas.price@aol.com |
| customer_id | full_name | state | |
|---|---|---|---|
| 15 | Chen Mendoza | chen_mendoza@yahoo.com | NC |
| 11 | Denise Huang | deniseh@aol.com | TX |
| 49 | Douglas Moore | douglas.moore@protonmail.com | OH |
| 25 | Douglas Price | douglas.price@aol.com |
Showing first 5 of 13 rows. These US customers have no phone on record but have state data.
Showing first 5 of 13 rows. These US customers have no phone on record but have state data.
Your final output should be a result set that meets the following requirements:
1. Filtering:
phone column IS NULL.state column IS NOT NULL.2. Columns:
customer_idYour final output should be a result set that meets the following requirements:
1. Filtering:
phone column IS NULL.state column IS NOT NULL.2. Columns:
customer_id| 2 | Marilyn Kelly | marilynkelly@yahoo.com | New York | NY | US | 2024-11-30 08:33:24 |
| 2 | Marilyn Kelly | marilynkelly@yahoo.com | New York | NY | US | 2024-11-30 08:33:24 |
| 3 | Andrea Miller | andrea_miller@zoho.com | +1-803-484-1106 | Winnipeg | MB | CA | 2025-06-22 16:35:50 |
| 3 | Andrea Miller | andrea_miller@zoho.com | +1-803-484-1106 | Winnipeg | MB | CA | 2025-06-22 16:35:50 |
| 4 | Luis Green | lgreen@aol.com | +1-544-304-2519 | San Antonio | TX | US | 2025-01-26 13:10:44 |
| 4 | Luis Green | lgreen@aol.com | +1-544-304-2519 | San Antonio | TX | US | 2025-01-26 13:10:44 |
| 5 | Anthony Alvarez | anthonya@protonmail.com | +1-749-327-7201 | Los Angeles | CA | US | 2024-10-01 14:28:15 |
| 5 | Anthony Alvarez | anthonya@protonmail.com | +1-749-327-7201 | Los Angeles | CA | US | 2024-10-01 14:28:15 |
| FL |
| FL |
| 41 | Elizabeth Patel | elizabethp@fastmail.com | AZ |
| 41 | Elizabeth Patel | elizabethp@fastmail.com | AZ |
full_namefull_nameemailemailstatestate3. Ordering:
3. Ordering:
full_name in ascending alphabetical order.customer_id in ascending order.full_name in ascending alphabetical order.customer_id in ascending order.