Find Customer Referee
Task: Find the names of the customer that are not referred by the customer with id = 2.
Table: Customer
+-------------+-------------+
| Column Name | Type |
+-------------+-------------+
| id | INT |
| name | varchar(25) |
| referee_id | INT |
+-------------+-------------+
Input: Customer table:
+----+------+------------+
| id | name | referee_id |
+----+------+------------+
| 1 | Will | null |
| 2 | Jane | null |
| 3 | Alex | 2 |
| 4 | Bill | null |
| 5 | Zack | 1 |
| 6 | Mark | 2 |
+----+------+------------+
Output:
+------+
| name |
+------+
| Will |
| Jane |
| Bill |
| Zack |
+------+ View Reference Solution & Explanation ▼
This query filters the table using basic `SELECT` and `WHERE` clauses to match the exact conditions specified in the problem.
SELECT name FROM Customer WHERE referee_id != 2 OR referee_id IS NULL;