<aside> 💡

Project Overview:

This project identifies customers who were not referred by the customer with id = 2. The solution demonstrates SQL skills in conditional filtering and handling NULL values.

</aside>


Problem Description:

Table: Customer

The task is to retrieve the name of customers whose referee_id is not equal to 2 or is NULL.


Solution:

The query filters the Customer table for rows where the referee_id is either not equal to 2 or is NULL.

SELECT
    name
FROM
    Customer
WHERE
    referee_id != 2
    OR referee_id IS NULL;


Explanation:

  1. Filtering Conditions:
  2. Selecting Columns:

Example Input and Output:

Input:

Customer Table: