Return customers whose referee is not a specific value, while also keeping customers with no referee.
You are given a table of customers with at least these columns:
id: customer identifiername: customer namereferee_id: identifier of the customer who referred them, or NULL if they were not referredWrite a query to return the names of customers who were not referred by the customer with id = 2.
A customer should be included if:
referee_id is anything other than 2, orreferee_id is NULL.Return the result set with the customer names in any order.
A Customer table containing customer records with columns similar to:
idnamereferee_idReturn one column:
namereferee_id may be NULL.referee_id = 2.Example 1
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 | +------+
Explanation
Exclude customers whose referee is 2. Keep rows where referee_id is NULL or any value other than 2.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.